Can anyone shed any light on how the CoreCompile task in TFS2010 (RC) Microsoft.TeamFoundation.Build targets generates the assembly references that are passed to csc.exe?
We are seeing references to both version 2.0 and 4.0 of System.Xml.dll (shown in bold below), however we are using the 'Specific Version: true' flag on the project assembly reference and there are no references to the 4.0 assembly in the btproj file:
C:\Windows\Microsoft.NET\Framework\v3.5\Csc.exe /noconfig /nowarn:1701,1702 /platform:x86 /errorreport:prompt /warn:4 /define:TRACE
/reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Configuration.dll
/reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll
**/reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll**
/reference:C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.dll
**/reference:C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Xml.dll**
/reference:C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Data.dll
/reference:C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Web.Services.dll
Update: I've checked the output of the ResolveAssemblyReferences target (from Microsoft.Common.targets) and can see that only the assemblies referenced in the project (i.e. the 2.0 framework assemblies) are included in the item list '_ResolveAssemblyReferenceResolvedFiles':
ResolveAssemblyReferenceResolvedFiles:
C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Configuration.dll;
C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll;
C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll
However, the CoreCompile target still includes the 4.0 assemblies as detailed above.
Update 2: Ok, I've tracked this down to an obscure bug in the AddBizTalkHiddenReferences target in the BizTalk build scripts. This particular target attempts to add additional assemblies, including the ones that are duplicated above.
However, it uses the GetCORSystemDirectory from 'mscoree.dll' which returns the installation directory of the common language runtime (CLR) that is loaded into the process, in this case the 4.0 framework loaded into MSBuild; as a result, the helper doesn't think it has the System.Xml assembly referenced and adds it, hence the duplicate.
Reference assemblies are resolved by ResolveAssemblyReferences target in the file Windows\Microsoft.NET\Framework\$(Version)\Microsoft.Common.targets based on the Reference items defined in your project file.
Related
The Poco Libraries can be really powerful and useful... but also stubbornly hard to build :-( I am now several days into a process of trying to upgrade from:
Poco 1.9.0, win32 build, including NetSSL_OpenSSL and Data/MySQL, on Windows 7, using MS Visual Studio 2015 successfully built via buildwin.cmd script from Windows Explorer since April 2018
to:
Poco 1.10.1, win32 and x64 builds, including NetSSL_OpenSSL and Data/MySQL (32-bit) or Data/PostgreSQL (64-bit), on Windows 10, using MS Visual Studio 2019, built via any means at all.
So far I cannot make the build process budge in any significant direction from my old build to my new target via any means... except possibly via CMake.
Since CMake appears to be the preferred way to build Poco, and nothing else (e.g. buildwin.cmd) works as expected, I am trying to rebuild the 32-bit DLLs so I can test with older proven components in my application. It looks promising. But the crypto build complains:
LINK : fatal error LNK1104: cannot open file 'libcrypto.lib' [S:\3rdparty\Poco-build32\Crypto\Crypto.vcxproj]
That's strange: in the entire Crypto.vcxproj file, there is no mention of libcrypto.lib at all, only libcrypto32MD.lib and libcrypto32MDd.lib. Why is it even looking for libcrypto.lib? Even so, if it is supposed to be finding libcrypto.lib, why doesn't it succeed when it is freshly installed in C:\Program Files (x86)\OpenSSL-Win32\lib and OPENSSL_ROOT_DIR is set to C:\Program Files (x86)\OpenSSL-Win32? What am I missing? I got to this point via:
cmake -HS:\3rdparty\Poco -B S:\3rdparty\Poco-build32 -G "Visual Studio 16 2019" -A win32
cmake --build s:\3rdparty\Poco-build32 --config RelWithDebInfo
UPDATE: in case I modified anything while trying to make it build in other ways (buildwin.cmd, Batch Build in Visual Studio), I set the entire Poco file structure aside, and unzipped a fresh copy. The OpenSSL install is also fresh and untouched. The x64 build produces the identical error...
There is a hidden readme file https://github.com/pocoproject/poco/blob/master/README. I'm quoting:
Through the Poco/Crypto/Crypto.h and Poco/Net/NetSSL.h header files,
Visual C++ will automatically link the libcrypto.lib and libssl.lib
libraries. If your OpenSSL libraries are named differently, compile
with the macro POCO_EXTERNAL_OPENSSL defined and edit the project
files accordingly.
You can try to re-compile with the POCO_EXTERNAL_OPENSSL macro set accordingly (see Foundation/include/Poco/Config.h). (source)
Or what I did. Edit the file Crypto/include/Poco/Crypto/Crypto.h, remove all if-else logic around pragmas and leave only libraries that use have:
#pragma comment(lib, "libcrypto64md.lib")
#pragma comment(lib, "libssl64md.lib")
This is not a direct answer - it is an alternative build path that has been confirmed to produce viable DLLs. Try:
Start command line tool from Visual Studio
Invoke vcvars32.bat or vcvars64.bat to ensure environment is correct for Win32 or x64 build.
I found these scripts in C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build
Ensure the Poco buildwin.cmd script is configured to specify location of OpenSSL include and lib sub-folders
you will likely have to modify the script between builds if building both 32- and 64-bit builds since openSSL-Win32 and openSSL-Win64 are separate installations
specify include and lib paths for other components the same way (e.g. MySQL and/or PostgreSQL, etc)
Edit the Poco "components" file to eliminate any components not required that will stop build
Invoke buildwin, e.g.:
buildwin 160 shared both Win32 samples notests
buildwin 160 shared both x64 samples notests
I want to make some bugfix in mono.
I have mono installed on my openSuse and download mono source code from github.
Then i want build System.Configuration project with this command:
xbuild System.Configuration-net_4_5.sln
and recieve 31 Errors, most of them like this
error CS0518: The predefined type 'System.Object' is not defined or imported
Also i recieve following warning:
warning : ProjectReference '..\corlib\corlib-net_4_5.csproj' not found, neither by guid 'some guid' nor by project file name 'path to project'
This project does exist in this location.
What's wrong?
Thanks.
You have to make the code change and then recompile the whole Mono following the instructions on how to compile Mono from source code. You cannot build individual projects, as the referenced projects cannot be resolved by 'xbuild' correctly.
Following from How can I build a targetting pack for Portable Class Libraries? and the advice in http://jpobst.blogspot.com/2012/04/mono-for-android-portable-libraries-in.html I've managed to build some monodroid example programs which use Portable Class Libraries.
However, if any of my input PCLs reference the System.Net assembly, then monodroid fails to package my apk - because it complains about File Not Found for System.Net.dll.
As I understand it (from http://docs.xamarin.com/android/about/assemblies), MonoDroid bundles all the System.Net functionality inside System.dll.
Is there any way I can get MonoDroid to use these PCLs which reference System.Net?
Is there any way I can get the monodroid packager to understand this System.net-> System redirection?
Or is there some pre-package step I could run that would "correct" the referencing just for monodroid?
Or any other suggestions?
Update with technical info:
The packaging process is currently failing at the level of:
"C:\Projects\Misc\MVVMCROSS\Sample - Tutorial\Tutorial\Tutorial.UI.Droid\Tutorial.UI.Droid.csproj" (SignAndroidPackage target) (1) ->
(_ResolveAssemblies target) ->
C:\Program Files (x86)\MSBuild\Novell\Novell.MonoDroid.Common.targets(441,2): error : Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.Net, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'. Perhaps it doesn't exist in the Mono for Android profile? [C:\Projects\Misc\MVVMCROSS\Sample - Tutorial\Tutorial\Tutorial.UI.Droid\Tutorial.UI.Droid.csproj]
C:\Program Files (x86)\MSBuild\Novell\Novell.MonoDroid.Common.targets(441,2): error : File name: 'System.Net.dll' [C:\Projects\Misc\MVVMCROSS\Sample - Tutorial\Tutorial\Tutorial.UI.Droid\Tutorial.UI.Droid.csproj]
C:\Program Files (x86)\MSBuild\Novell\Novell.MonoDroid.Common.targets(441,2): error : at Monodroid.Tuner.MonoDroidResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters) [C:\Projects\Misc\MVVMCROSS\Sample - Tutorial\Tutorial\Tutorial.UI.Droid\Tutorial.UI.Droid.csproj]
C:\Program Files (x86)\MSBuild\Novell\Novell.MonoDroid.Common.targets(441,2): error : at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(List`1 assemblies, AssemblyDefinition assembly) [C:\Projects\Misc\MVVMCROSS\Sample - Tutorial\Tutorial\Tutorial.UI.Droid\Tutorial.UI.Droid.csproj]
C:\Program Files (x86)\MSBuild\Novell\Novell.MonoDroid.Common.targets(441,2): error : at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(List`1 assemblies, AssemblyDefinition assembly) [C:\Projects\Misc\MVVMCROSS\Sample - Tutorial\Tutorial\Tutorial.UI.Droid\Tutorial.UI.Droid.csproj]
C:\Program Files (x86)\MSBuild\Novell\Novell.MonoDroid.Common.targets(441,2): error : at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(List`1 assemblies, AssemblyDefinition assembly) [C:\Projects\Misc\MVVMCROSS\Sample - Tutorial\Tutorial\Tutorial.UI.Droid\Tutorial.UI.Droid.csproj]
C:\Program Files (x86)\MSBuild\Novell\Novell.MonoDroid.Common.targets(441,2): error : at Xamarin.Android.Tasks.ResolveAssemblies.Execute() [C:\Projects\Misc\MVVMCROSS\Sample - Tutorial\Tutorial\Tutorial.UI.Droid\Tutorial.UI.Droid.csproj]
This is occurring within the MSBuild task:
<!-- Find all the assemblies this app requires -->
<ResolveAssemblies
Assemblies="$(ProjectDir)$(OutDir)$(TargetFileName);#(ReferencePath)"
I18nAssemblies="$(MandroidI18n)"
LinkMode="$(AndroidLinkMode)"
ReferenceAssembliesDirectory="$(TargetFrameworkDirectory)">
<Output TaskParameter="ResolvedAssemblies" ItemName="ResolvedAssemblies" />
<Output TaskParameter="ResolvedUserAssemblies" ItemName="ResolvedUserAssemblies" />
<Output TaskParameter="ResolvedFrameworkAssemblies" ItemName="ResolvedFrameworkAssemblies" />
<Output TaskParameter="ResolvedSymbols" ItemName="ResolvedSymbols" />
</ResolveAssemblies>
imported from:
<UsingTask TaskName="Xamarin.Android.Tasks.ResolveAssemblies" AssemblyFile="Novell.MonoDroid.Build.Tasks.dll" />
A possible solution (assuming MonoDroid supports type forwarding) is to have a System.Net.dll assembly which type forwards the relevant types to System.dll.
In the full .NET Framework, I believe those System.Net types are in System.dll, and if you look in System.Net.dll on .NET 4.0.3 or 4.5, you will see TypeForwardedToAttributes for those types, which allow those type references to System.Net.dll in a portable library to be redirected to System.dll. Jeremy Likness's blog post series on Understanding Portable Libraries goes into some detail about how this all works.
The references in a portable library refer to the full strong name of System.Net.dll. So you couldn't produce a correctly signed assembly with those type forwards yourself, since you don't have the private key. However, MonoDroid may handle strong names or signature validation differently. So you might be able to produce a System.Net.dll with the type forwards that MonoDroid would accept, and package it with your MonoDroid application.
IDE: VS2005
Say I am using Poco library and the executable needs below dlls. I have to put them in same directory where the executable is.
msjava.dll
msvcp80.dll
msvcr80.dll
PocoFoundation.dll
PocoNet.dll
Is there any way that can build a dll-free executable? Thanks.
They don't have to be in the same directory. They can be in another directory if your PATH variables includes the directory they are in.
It looks like the Poco libraries can be downloaded as source, so you should be able to build them as static libraries and make a stand alone executable.
Update
For the msvc DLL's, you can build against static libraries. Bring up the properties of your project, go to C/C++, Code Generation and modify "Runtime Library". Make sure to choose a library other then "Multi-threaded DLL" or "Multi-threaded Debug DLL." You will also want to make sure you do that for the Poco libraries as well.
Is it possible to specify the target platform (x64, x86) when building a project?
I have a build task that looks as follows:
<MSBuild Projects="%(AgentProjectFiles.FullPath)" Properties="Architecture=x86;Configuration=$(Configuration);Optimize=$(Optimize);Platform=$(Platform);OutputPath=$(OutputDirectory)\Agent\;ReferencePath=$(ReferencePath);DebugSymbols=$(DebugSymbols);DebugType=none;" />
As you can probably tell, I've thrown everything possible I have seen online into the Properties attribute in the hope that it will work. You will notice that for the Architecture property I've set it to be x86 explicitly. the $(Platform) is also set to x86. I've tried a number of permutations, without success.
Unfortunately, it seems that no matter what gets put into these properties, my class libraries are x86, but my executables are x64.
I thought perhaps the problem could be that the build properties specified in the project file itself were causing MSBuild to ignore the ones I pass through from MSBuild, but after changing these to x86, I still have the same problem.
Any ideas?
In the declaration of the AgentProjectFiles item are you defining the Properties metadata. So does it look like:
<ItemGroup>
<AgentProjectFiles Include="something.proj">
<Properties>SOME VALUES HERE</Properties>
</AgentProjectFiles>
</ItemGroup>
If you have defined that then the properties passed into the Properties attribute of the MSBuild task are ignored. I've bloged about this MSBuild: Properties and AdditionalProperties Known Metadata.
Sayed Ibrahim Hashimi
My Book: Inside the Microsoft Build Engine : Using MSBuild and Team Foundation Build