Using ProjectReference for .vcxproj in .csproj failing the build with msbuild - msbuild

I have c# project with .csproj extension, in this file I am referring a .vcxproj (C++). When I try to build the project with msbuild, the build fails with following error:
Program.cs(13,25): error CS0246: The type or namespace name 'CppLibrary' could not be found (are you missing a using di
rective or an assembly reference?) [C:\Work\CppTest\CSharp\CSharp.csproj]
Done Building Project "C:\Work\CppTest\CSharp\CSharp.csproj" (default targets) -- FAILED.
Done Building Project "C:\Work\CppTest\CppTest.sln" (default targets) -- FAILED.
How can we use .vcxproj in .csproj?

Related

building mono's System.Configuration project failed with error "ProjectReference corlib-net not found"

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.

Why is my packaging step failing in teambuild?

I'm just the build guy, I didn't write the web app and don't know much about web apps (as will become abundantly clear, I'm sure).
So dude tells me we need to run "msbuild /T:Package /P:Configuration=Release" to package his app. Okay. There's multiple solutions in his build definition and only one of them which needs the Package target so I wrote a stupid little msbuild proj file to add to his TFS build definition with a default target that looks like this:
<Target Name="Package" Condition=" '$(Configuration)' == 'Release' ">
<MSBuild Projects="HisApp.csproj"
Properties="Configuration=$(Configuration)"
Targets="Package" />
</Target>
Added that to the build definition and it fails with this:
Build started 8/7/2012 7:17:48 PM.
Project "C:\path\to\MyDumbScript.proj" on node 1 (default targets).
Package:
Project "C:\Path\to\MyDumbScript.proj" (1) is building "C:\Path\to\HisApp.csproj" (2) on node 1 (Package target(s)).
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets(1737,5): error : Value cannot be null. [C:\Path\to\HisApp.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets(1737,5): error : Parameter name: type [C:\Path\to\HisApp.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets(1737,5): error : Unknown error (0x80005000) [C:\Path\to\HisApp.csproj]
Done Building Project "C:\Path\to\HisApp.csproj" (Package target(s)) -- FAILED.
Done Building Project "C:\Path\to\MyDumbScript.proj" (default targets) -- FAILED.
Build FAILED.
"C:\Path\to\MyDumbScript.proj" (default target) (1) ->
"C:\Path\to\HisApp.csproj" (Package target) (2) ->
(GetProjectWebProperties target) ->
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets(1737,5): error : Value cannot be null. [C:\Path\to\HisApp.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets(1737,5): error : Parameter name: type [C:\Path\to\HisApp.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets(1737,5): error : Unknown error (0x80005000) [C:\Path\to\HisApp.csproj]
0 Warning(s)
2 Error(s)
Time Elapsed 00:00:00.82
So that's as clear as mud.
Questions:
Is there some more straightforward way to call the package target from Team Build when the build definition calls multiple solutions?
Why's this failing?
Thanks.
It looks like the errors were due to IIS not being enabled on the build machine.
When I enabled the “Web Management Tools” and “World Wide Web Services” features on the build machine the build failed in new and more interesting (and less opaque) ways.
As for the question of how better to call the package target from Team Build, I'd be happy to hear answers, but this works now.

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/

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?

disable or remove ASPNETCOMPILER warning CS1685

We are using msbuild to build our .NET solution.
Does anyone know how to get rid of these warnings at the end of the build?
(Build target) ->
ASPNETCOMPILER : warning CS1685: The predefined type 'Microsoft.CSharp.RuntimeBinder.Binder' is defined in multiple
assemblies in the global alias; using definition from 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framewo
rk.NETFramework\v4.0\Microsoft.CSharp.dll' [C:\Projects\Trunk\dev\source\UserInterface.metaproj]
ASPNETCOMPILER : warning CS1685: The predefined type 'Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags' is defined
in multiple assemblies in the global alias; using definition from 'c:\Program Files (x86)\Reference Assemblies\Micros
oft\Framework.NETFramework\v4.0\Microsoft.CSharp.dll' [C:\Projects\Trunk\dev\source\UserInterface.metaproj]
ASPNETCOMPILER : warning CS1685: The predefined type 'Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo' is defined
in multiple assemblies in the global alias; using definition from 'c:\Program Files
....
several pages of these warnings.
It is not recommend to disable warnings (they are here to warn you...). But if you really want to skip them you can add "nowarn=1695" to your command line. For example
MsBuild.exe UserInterface.metaproj /t:Build /p:Configuration=Release;nowarn=1695