Error when compiling c# project with reference to external DLL - dll

I'm trying to compile the following c# code which relies on the external DLL which source code is located there
So at first I compile the DLL project source code through:
dotnet build NtApiDotNet\NtApiDotNet.Core.csproj -c Release
I obtain the NtApiDotNet.dll, so everything good until there.
But, then I'm trying to compile the c# source code referencing the previous DLL with the following command line:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe /unsafe /platform:anycpu /r:NtApiDotNet.dll /out:poc.exe .\PulseLogPrivesc.cs
I obtain the following error log entries:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe /unsafe /platform:anycpu /r:NtApiDotNet.dll /out:poc.exe .\PulseLogPrivesc.cs
Microsoft (R) Visual C# Compiler version 4.7.2556.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.
This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest version. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240
PulseLogPrivesc.cs(72,17): error CS0012: The type 'System.Object' is defined in an assembly that is
not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
NtApiDotNet.dll: (Location of symbol related to previous error)
PulseLogPrivesc.cs(72,17): error CS0012: The type 'System.IDisposable' is defined in an assembly that
is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
NtApiDotNet.dll: (Location of symbol related to previous error)
PulseLogPrivesc.cs(72,17): error CS0012: The type 'System.IConvertible' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
NtApiDotNet.dll: (Location of symbol related to previous error)
PulseLogPrivesc.cs(72,17): error CS0012: The type 'System.ValueType' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
NtApiDotNet.dll: (Location of symbol related to previous error)
NtApiDotNet.dll: error CS0455: Type parameter 'A' inherits conflicting constraints 'System.ValueType'
and 'System.IConvertible'
PulseLogPrivesc.cs(169,21): error CS0012: The type 'System.Enum' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
NtApiDotNet.dll: (Location of symbol related to previous error)
PulseLogPrivesc.cs(174,13): error CS0012: The type 'System.Runtime.InteropServices.SafeBuffer' is
defined in an assembly that is not referenced. You must add a reference to assembly
'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
NtApiDotNet.dll: (Location of symbol related to previous error)
PulseLogPrivesc.cs(186,21): error CS1061: 'NtApiDotNet.NtMappedSection' does not contain a definition
for 'ReadArray' and no extension method 'ReadArray' accepting a first argument of type
'NtApiDotNet.NtMappedSection' could be found (are you missing a using directive or an assembly reference?)
PulseLogPrivesc.cs(191,21): error CS1061: 'NtApiDotNet.NtMappedSection' does not contain a definition
for 'WriteArray' and no extension method 'WriteArray' accepting a first argument of type
'NtApiDotNet.NtMappedSection' could be found (are you missing a using directive or an assembly reference?)
I tried to locate the external DLL on different folders: current directory, csc.exe directory.
Do you know what is the problem?
I also tried to compile the DLL from Visual Studio but I'm getting
the following error message

Related

ILMerge, .NET 4, NuGet: Unresolved assembly reference not allowed: CommandLine

ILMerge, .NET 4, NuGet: Unresolved assembly reference not allowed: CommandLine
I'm trying to pack my project into single dll.
I'm using:
- Visual Studio 2015
- NuGet
- ILMerge
To achieve my goal, I'd took ILMerge batch file
Added a post-build event:
"d:\#programming\#visual_studio\merge_all.bat" "$(TargetPath)" $(ConfigurationName)
Then slightly modified batch file to get rid of duplicate errors and add some hooks to try to eliminate "Unresolved assembly reference" error.
Unfortunately, none of Google Suggestions
Brought any relief.
So, I still got an error:
Unresolved assembly reference not allowed: CommandLine.
Here's my ILMerge batch file:
#ECHO OFF
rem # usage
rem # "path\to\merge_all.bat" "$(TargetPath)" $(ConfigurationName)
rem # "d:\#programming\#visual_studio\merge_all.bat" "$(TargetPath)" $(ConfigurationName)
rem # set .NET version and output folder name
set net_version=v4
set net_path="C:\Windows\Microsoft.NET\Framework\v4.0.30319"
set net_path_v1="%ProgramFiles%\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client"
set net_path_v2="%ProgramFiles%\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0"
set net_path_v3="%ProgramFiles%\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6"
set target_platform=%net_version%,%net_path_v3%
set lib_path="%ProgramFiles%\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0"
set output=merged
set ILMerge=%ProgramFiles%\Microsoft\ILMerge\ILMerge.exe
rem # parsing arguments
set target_path=%1
set target_file=%~nx1
set target_dir=%~dp1
set ConfigurationName=%2
rem # set output path and result file path
set outdir=%target_dir%%output%
set result=%outdir%\%target_file%
set log_file="%outdir%\merge.log"
set primary_assembly=%target_path%
rem # a little looping voodoo from microsoft to get rid of "duplicate" error
setlocal EnableDelayedExpansion
set "other_assemblies="
for %%f in (%target_dir%*.dll) do (
if NOT %%~nxf==%target_file% (
set "other_assemblies=!other_assemblies! %target_dir%%%~nxf"
)
)
setlocal DisableDelayedExpansion
rem # print info
#echo Start %ConfigurationName% Merging %target_file%.
#echo Target: %target_path%
#echo target_dir: %target_dir%
#echo Config: %ConfigurationName%
#echo Log: %log_file%
#echo primary assembly: %primary_assembly%
#echo other assemblies: %other_assemblies%
rem # recreate outdir
IF EXIST "%outdir%" rmdir /S /Q "%outdir%"
md "%outdir%"
set options= /wildcards /targetplatform:%target_platform% /log:%log_file% /out:"%result%" %primary_assembly% %other_assemblies%
rem # run merge cmd
#echo Merging: '"%ILMerge%" %options%'
"%ILMerge%" %options%
rem # if succeded
IF %ErrorLevel% EQU 0 (
rem # clear real output folder and put there result assembly
IF %ConfigurationName%==Release (
del %target_dir%*.*
del %target_dir%*.dll
del %target_dir%*.pdb
del %target_dir%*.xml
del %target_dir%*.*
copy %result% %target_dir%
rmdir /S /Q %outdir%
set result=%target_path%
#echo Result: %target_file% "-> %target_path%"
) ELSE (
#echo Result: %target_file% "-> %result%" )
set status=succeded
set errlvl=0
) ELSE (
set status=failed
set errlvl=1
)
#echo Merge %status%
exit %errlvl%
Here's the output of build process:
1>------ Rebuild All started: Project: YouTrackSharpApiWrapper, Configuration: Debug Any CPU ------
1>D:\#programming\#visual_studio\YouTrackSharpApiWrapper\ApiWrapper.cs(59,21,59,22): warning CS0168: The variable 'e' is declared but never used
1> YouTrackSharpApiWrapper -> D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharpApiWrapper.dll
1> Start Debug Merging YouTrackSharpApiWrapper.dll.
1> Target: "D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharpApiWrapper.dll"
1> target_dir: D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\
1> Config: Debug
1> Log: "D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\merged\merge.log"
1> primary assembly: "D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharpApiWrapper.dll"
1> other assemblies: D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\EasyHttp.dll D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\JsonFx.dll D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharp.dll
1> Merging: '"C:\Program Files (x86)\Microsoft\ILMerge\ILMerge.exe" /wildcards /targetplatform:v4,"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6" /log:"D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\merged\merge.log" /out:"D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\merged\YouTrackSharpApiWrapper.dll" "D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharpApiWrapper.dll" D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\EasyHttp.dll D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\JsonFx.dll D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharp.dll'
1> Merge failed
1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(4714,5): error MSB3073: The command ""d:\#programming\#visual_studio\merge_all.bat" "D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharpApiWrapper.dll" Debug" exited with code 1.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
And here's the log of ILMerge:
ILMerge version 2.12.803.0
Copyright (C) Microsoft Corporation 2004-2006. All rights reserved.
ILMerge /wildcards /targetplatform:v4,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6 /log:D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\merged\merge.log /out:D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\merged\YouTrackSharpApiWrapper.dll D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharpApiWrapper.dll D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\EasyHttp.dll D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\JsonFx.dll D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharp.dll
Set platform to 'v4', using directory 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6' for mscorlib.dll
Running on Microsoft (R) .NET Framework v2.0.50727
mscorlib.dll version = 2.0.0.0
The list of input assemblies is:
D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharpApiWrapper.dll
D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\EasyHttp.dll
D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\JsonFx.dll
D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharp.dll
The number of files matching the pattern D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharpApiWrapper.dll is 1.
D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharpApiWrapper.dll
Trying to read assembly from the file 'D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharpApiWrapper.dll'.
Successfully read in assembly.
There were no errors reported in YouTrackSharpApiWrapper's metadata.
The number of files matching the pattern D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\EasyHttp.dll is 1.
D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\EasyHttp.dll
Trying to read assembly from the file 'D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\EasyHttp.dll'.
Successfully read in assembly.
There were no errors reported in EasyHttp's metadata.
The number of files matching the pattern D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\JsonFx.dll is 1.
D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\JsonFx.dll
Trying to read assembly from the file 'D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\JsonFx.dll'.
Can not find PDB file. Debug info will not be available for assembly 'D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\JsonFx.dll'.
Successfully read in assembly.
There were no errors reported in JsonFx's metadata.
The number of files matching the pattern D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharp.dll is 1.
D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharp.dll
Trying to read assembly from the file 'D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharp.dll'.
Successfully read in assembly.
There were no errors reported in YouTrackSharp's metadata.
Checking to see that all of the input assemblies have a compatible PeKind.
YouTrackSharpApiWrapper.PeKind = ILonly
EasyHttp.PeKind = ILonly
JsonFx.PeKind = ILonly
YouTrackSharp.PeKind = ILonly
All input assemblies have a compatible PeKind value.
AssemblyResolver: Assembly 'EasyHttp' is referencing assembly 'System.Core'.
AssemblyResolver: Attempting referencing assembly's directory.
AssemblyResolver: Did not find assembly in referencing assembly's directory.
AssemblyResolver: Attempting input directory.
AssemblyResolver: Did not find assembly in input directory.
AssemblyResolver: Attempting user-supplied directories.
AssemblyResolver: No user-supplied directories.
AssemblyResolver: Attempting framework directory.
Can not find PDB file. Debug info will not be available for assembly 'System.Core'.
Resolved assembly reference 'System.Core' to 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.Core.dll'. (Used framework directory.)
AssemblyResolver: Assembly 'YouTrackSharp' is referencing assembly 'System.Management.Automation'.
AssemblyResolver: Attempting referencing assembly's directory.
AssemblyResolver: Did not find assembly in referencing assembly's directory.
AssemblyResolver: Attempting input directory.
AssemblyResolver: Did not find assembly in input directory.
AssemblyResolver: Attempting user-supplied directories.
AssemblyResolver: No user-supplied directories.
AssemblyResolver: Attempting framework directory.
AssemblyResolver: Did not find assembly in framework directory.
AssemblyResolver: Unable to resolve reference. (It still might be found, e.g., in the GAC.)
AssemblyResolver: Assembly 'YouTrackSharp' is referencing assembly 'CommandLine'.
AssemblyResolver: Attempting referencing assembly's directory.
AssemblyResolver: Did not find assembly in referencing assembly's directory.
AssemblyResolver: Attempting input directory.
AssemblyResolver: Did not find assembly in input directory.
AssemblyResolver: Attempting user-supplied directories.
AssemblyResolver: No user-supplied directories.
AssemblyResolver: Attempting framework directory.
AssemblyResolver: Did not find assembly in framework directory.
AssemblyResolver: Unable to resolve reference. (It still might be found, e.g., in the GAC.)
Using assembly 'YouTrackSharpApiWrapper' for assembly-level attributes for the target assembly.
Merging assembly 'YouTrackSharpApiWrapper' into target assembly.
Merging assembly 'EasyHttp' into target assembly.
Merging assembly 'JsonFx' into target assembly.
Assembly level attribute 'System.Security.AllowPartiallyTrustedCallersAttribute' from assembly 'JsonFx' being deleted from target assembly
Merging assembly 'YouTrackSharp' into target assembly.
Copying 1 Win32 Resources from assembly 'YouTrackSharpApiWrapper' into target assembly.
There were no errors reported in the target assembly's metadata.
ILMerge: Writing target assembly 'D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\merged\YouTrackSharpApiWrapper.dll'.
AssemblyResolver: Assembly 'YouTrackSharp' is referencing assembly 'Microsoft.CSharp'.
AssemblyResolver: Attempting referencing assembly's directory.
AssemblyResolver: Did not find assembly in referencing assembly's directory.
AssemblyResolver: Attempting input directory.
AssemblyResolver: Did not find assembly in input directory.
AssemblyResolver: Attempting user-supplied directories.
AssemblyResolver: No user-supplied directories.
AssemblyResolver: Attempting framework directory.
Can not find PDB file. Debug info will not be available for assembly 'Microsoft.CSharp'.
Resolved assembly reference 'Microsoft.CSharp' to 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\Microsoft.CSharp.dll'. (Used framework directory.)
An exception occurred during merging:
Unresolved assembly reference not allowed: CommandLine.
at System.Compiler.Ir2md.GetAssemblyRefIndex(AssemblyNode assembly)
at System.Compiler.Ir2md.GetTypeRefIndex(TypeNode type)
at System.Compiler.Ir2md.VisitReferencedType(TypeNode type)
at System.Compiler.Ir2md.GetMemberRefIndex(Member m)
at System.Compiler.Ir2md.GetMethodToken(Method m)
at System.Compiler.Ir2md.VisitConstruct(Construct cons)
at System.Compiler.Ir2md.VisitExpressionList(ExpressionList expressions)
at System.Compiler.Ir2md.VisitConstruct(Construct cons)
at System.Compiler.Ir2md.VisitAssignmentStatement(AssignmentStatement assignment)
at System.Compiler.Ir2md.VisitBlock(Block block)
at System.Compiler.Ir2md.VisitBlock(Block block)
at System.Compiler.Ir2md.VisitMethodBody(Method method)
at System.Compiler.Ir2md.VisitMethod(Method method)
at System.Compiler.Ir2md.VisitClass(Class Class)
at System.Compiler.Ir2md.VisitModule(Module module)
at System.Compiler.Ir2md.SetupMetadataWriter(String debugSymbolsLocation)
at System.Compiler.Ir2md.WritePE(Module module, String debugSymbolsLocation, BinaryWriter writer)
at System.Compiler.Writer.WritePE(String location, Boolean writeDebugSymbols, Module module, Boolean delaySign, String keyFileName, String keyName)
at System.Compiler.Writer.WritePE(CompilerParameters compilerParameters, Module module)
at ILMerging.ILMerge.Merge()
at ILMerging.ILMerge.Main(String[] args)
Sorry for a long post, but I've got not enough mana to insert more than 2 links, so had to paste log right in thread, and Markdown support here really sucks.
AssemblyResolver: Assembly 'YouTrackSharp' is referencing assembly 'CommandLine'.
It seems like some your components has a reference to CommandLine component, while the ILMerge parameter string doesn't contains that reference (as I can see from your log).
In attempt to resolve this issue try to specify /useFullPublicKeyForReferences parameter for ILMerge call. If it doesn't help, try to specify CommandLine library location at the end.

why is gmcs command in bash(mono) missing the namespace `System.Threading'?

I input this command
gmcs -t:library Program.cs
and get this error
Program.cs(6,14): error CS0234: The type or namespace name `Tasks' does not exist in the namespace `System.Threading'. Are you missing an assembly reference?
I get I have to give it the paths and everything, but how? can't find the way to do it
gmcs targets the .NET 2.0 profile, Task didn't exist back then.
On a recent Mono just use mcs, as gmcs is deprecated and was removed from Mono 4.0.

MSBuild failing on Automated Test project

I just added an automated test project to my C# solution and checked it into my build server.
When the build script runs using MSBuild (.NET Framework 3.5), it gives me several errors (such as the following):
**cs(2,17): error CS0234: The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
**.cs(21,17): error CS0246: The type or namespace name 'TestContext' could not be found (are you missing a using directive or an assembly reference?)
**.cs(73,10): error CS0246: The type or namespace name 'TestMethod' could not be found (are you missing a using directive or an assembly reference?)
**.cs(73,10): error CS0246: The type or namespace name 'TestMethodAttribute' could not be found (are you missing a using directive or an assembly reference?)
**.cs(14,6): error CS0246: The type or namespace name 'TestClass' could not be found (are you missing a using directive or an assembly reference?)
**.cs(14,6): error CS0246: The type or namespace name 'TestClassAttribute' could not be found (are you missing a using directive or an assembly reference?)
When I run the .NET 3.5 msbuild on my computer, it builds correctly.
The build server does not have .NET 4.0 on it, and stepping it up is not an option. Can anyone suggest what could be causing the difference and what I can do to get the test project building successfully ?
Thanks
As stated above, the easiest thing to do is to install the appropriate version of Visual Studio on your build server to get all of the MSTest dependencies. This is what is typically done.
If for whatever reason you can't do that, the following page shows how to get your dependencies available without the VS2008 install:
http://www.shunra.com/shunrablog/index.php/2009/04/23/running-mstest-without-visual-studio/

Is it possible to use a Portable Class Library that references System.Net in MonoDroid?

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.

msbuild - UnitTestFramework reference could not be resolved

I'm trying to run msbuild in Jenkins.
When it reaches the UniTest-Project an error occures:
Project "C:\Program Files (x86)\Jenkins\jobs\***\workspace\***.sln" (1) is building "C:\Program Files (x86)\Jenkins\jobs\***\workspace\***.unitTests\***.unitTests.csproj" (4) on node 0 (default targets).
Project file contains ToolsVersion="4.0", which is not supported by this version of MSBuild. Treating the project as if it had ToolsVersion="3.5".
ResolveAssemblyReferences:
Primary reference "Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL".
Could not find dependent files. Could not load file or assembly 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets : warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
For SearchPath "{Registry:Software\Microsoft\.NetFramework,v4.0,AssemblyFoldersEx}".
Considered "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VSTSDB\Microsoft.VisualStudio.QualityTools.UnitTestFramework.exe", but it didn't exist.
Considered "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VSTSDB\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll", but it didn't exist.
Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp\2.0\Runtime\v4.0\Microsoft.VisualStudio.QualityTools.UnitTestFramework.exe", but it didn't exist.
Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp\2.0\Runtime\v4.0\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll", but it didn't exist.
Considered "C:\Program Files (x86)\MySQL\MySQL Connector Net 6.3.6\Assemblies\v2.0\Microsoft.VisualStudio.QualityTools.UnitTestFramework.exe", but it didn't exist.
Considered "C:\Program Files (x86)\MySQL\MySQL Connector Net 6.3.6\Assemblies\v2.0\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll", but it didn't exist.
Considered "C:\Program Files (x86)\MySQL\MySQL Connector Net 6.3.6\Assemblies\v4.0\Microsoft.VisualStudio.QualityTools.UnitTestFramework.exe", but it didn't exist.
Considered "C:\Program Files (x86)\MySQL\MySQL Connector Net 6.3.6\Assemblies\v4.0\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll", but it didn't exist.
Considered "C:\Program Files (x86)\Microsoft.NET\Primary Interop Assemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.exe", but it didn't exist.
Considered "C:\Program Files (x86)\Microsoft.NET\Primary Interop Assemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll", but it didn't exist.
Considered "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.exe", but it didn't exist.
CalculatorServiceTest.cs(1,17): error CS0234: The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
CalculatorServiceTest.cs(11,10): error CS0246: The type or namespace name 'TestMethod' could not be found (are you missing a using directive or an assembly reference?)
CalculatorServiceTest.cs(11,10): error CS0246: The type or namespace name 'TestMethodAttribute' could not be found (are you missing a using directive or an assembly reference?)
CalculatorServiceTest.cs(24,10): error CS0246: The type or namespace name 'TestMethod' could not be found (are you missing a using directive or an assembly reference?)
CalculatorServiceTest.cs(24,10): error CS0246: The type or namespace name 'TestMethodAttribute' could not be found (are you missing a using directive or an assembly reference?)
CalculatorServiceTest.cs(37,10): error CS0246: The type or namespace name 'TestMethod' could not be found (are you missing a using directive or an assembly reference?)
CalculatorServiceTest.cs(37,10): error CS0246: The type or namespace name 'TestMethodAttribute' could not be found (are you missing a using directive or an assembly reference?)
CalculatorServiceTest.cs(6,6): error CS0246: The type or namespace name 'TestClass' could not be found (are you missing a using directive or an assembly reference?)
CalculatorServiceTest.cs(6,6): error CS0246: The type or namespace name 'TestClassAttribute' could not be found (are you missing a using directive or an assembly reference?)
Done Building Project "C:\Program Files (x86)\Jenkins\jobs\***\workspace\***.unitTests\***.unitTests.csproj" (default targets) -- FAILED.
Done Building Project "C:\Program Files (x86)\Jenkins\jobs\***\workspace\***.sln" (default targets) -- FAILED.
Build FAILED.
Any suggestions what the problem could be? Running ms build from the command works for the solution and without any additional parameters when the project was compiles in VS bevor. After a clean solution the same errors occur. Must be some parameter or reference problem; Line two talks bout v4 and v3.5 problems; but i can't figure out how to solve this.
Greets
Error info directly shows that you use incorrect version of MSBuild
This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
Try to rebuild with MSBuild 4.0
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe *.sln /t:rebuild
OR/AND from VS2010 Command Line.
I had a similar problem which seemed to be caused by running Jenkins as a service under the SYSTEM account. Somehow cmd.exe was not referencing all the necessary environment variables to be able to find my NUnit assemblies.
If you're running Jenkins as a service, try setting it to run as your user account and see if that helps.
Im building from the default windows cmd using:
C:...\MSBuild.exe *.sln
The solution-projects are all 3.5; only the Unit-Test Project is 4.0 (as you can't change this)
I just mentioned, that building it that way works, when i build it first with VS and don't deleted (clean solution) the binaries. Never mind.
How do i have to use msbuild from cmd to build a *.sln including unittests?