Quantcast
Channel: MSBuild forum
Viewing all articles
Browse latest Browse all 2763

Builds in IDE but not with MSBuild - reference issue

$
0
0

I have two projects, one is a library (MyLibrary) and one is a stub for that library (MyLibraryStub). The stub is for using in build time unit testing.  I have created a solution that has only these two projects in it and this will build fine from the IDE. Our CSPROJ files are set up such that when they build on a TFS build agent, the binaries are dropped into a _Binaries folder that a post build task then picks up and copies them to a restricted build location.  You will see one additional reference to a library called Aspex that is a custom library used for DAL (generalized interfaces to stored procedures). As I mentioned it builds in the IDE but not from the command line and in looking at the diagnostic build output I noticed the problem. When it is built from the command line, MSBUILD adds an additional reference not only to MyLibrary.dll but also the source file MyLibrary.cs!  I’ve tried from both the x64 VS2010 command line and the standard VS2010 command line. I’ve tried forcing bit-ness with /p:Plaform=”Any CPU”, “x86” and “x64”.  The CSC commands that are used are:

 

When run from the IDE:

 

 C:\Windows\Microsoft.NET\Framework\v4.0.30319\Csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /errorreport:prompt /warn:4 /doc:MyLibraryStub.xml /define:DEBUG;TRACE

/reference:C:\TFS\MyFolder\MyTFSBranch\MyProduct\_Binaries\Debug\MyLibrary.dll

/reference:C:\TFS\MyFolder\MyTFSBranch\MyProduct\DB\DataAccess\MyLibraryStub\..\..\..\..\SharedBinaries\Aspex\8.2.10250.1\Aspex.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\mscorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Data.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Xml.dll" /debug+ /debug:full /filealign:512

/keyfile:C:\TFS\MyFolder\MyTFSBranch\MyProduct\DB\DataAccess\MyLibraryStub\..\..\..\MyProduct.snk /optimize- /out:obj\Debug\MyLibraryStub.dll /resource:obj\Debug\Msn.Ads.ABC.DataAccess.XmlData.resources /target:library C:\TFS\MyFolder\MyTFSBranch\MyProduct\DB\DataAccess\MyLibraryStub\..\..\..\AssemblyVersionAndInfo.cs C:\TFS\MyFolder\MyTFSBranch\MyProduct\DB\DataAccess\MyLibraryStub\..\..\..\CLSComplianceTrue.cs MyLibraryDBDataStub.cs

AssemblyInfo.cs XmlData.Designer.cs "C:\Users\markhow\AppData\Local\Temp\.NETFramework,Version=v4.0.AssemblyAttributes.cs"

 

 

When running MSBUILD from the command line:

 

 c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /errorreport:prompt /warn:4 /doc:MyLibraryStub.xml /define:DEBUG;TRACE

/reference:C:\TFS\MyFolder\MyTFSBranch\MyProduct\_Binaries\Debug\MyLibrary.dll

/reference:C:\TFS\MyFolder\MyTFSBranch\MyProduct\DB\MyLibrary\..\..\DB\MyLibrary\MyLibraryDB.cs

/reference:C:\TFS\MyFolder\MyTFSBranch\MyProduct\DB\DataAccess\MyLibraryStub\..\..\..\..\SharedBinaries\Aspex\8.2.10250.1\Aspex.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\mscorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Data.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Xml.dll" /debug+ /debug:full /filealign:512

/keyfile:C:\TFS\MyFolder\MyTFSBranch\MyProduct\DB\DataAccess\MyLibraryStub\..\..\..\MyProduct.snk /optimize- /out:obj\X64\Debug\MyLibraryStub.dll /resource:obj\X64\Debug\Msn.Ads.ABC.DataAccess.XmlData.resources /target:library C:\TFS\MyFolder\MyTFSBranch\MyProduct\DB\DataAccess\MyLibraryStub\..\..\..\AssemblyVersionAndInfo.cs C:\TFS\MyFolder\MyTFSBranch\MyProduct\DB\DataAccess\MyLibraryStub\..\..\..\CLSComplianceTrue.cs MyLibraryDBDataStub.cs

AssemblyInfo.cs XmlData.Designer.cs "C:\Users\markhow\AppData\Local\Temp\.NETFramework,Version=v4.0.AssemblyAttributes.cs"

 

The project reference in MyLibraryStub.csproj is very simple:

<ProjectReference Include="..\..\MyLibrary\MyLibrary.csproj">
   <Project>{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}</Project>
   <Name>MyLibrary</Name>

</ProjectReference>

 

 

The error that I get from the command line indicates that MyLibraryDB.cs does not have metadata, which it will not because it is a source file, not an assembly. Here is the error:

 

CSC : fatal error CS0009: Metadata file 'c:\TFS\MyFolder\MyTFSBranch\MyProduct\DB\MyLibrary\MyLibraryDB.cs' could not be opened -- 'File is corrupt.' [C:\TFS\MyFolder\MyTFSBranch\MyProduct\DB\DataAccess\MyLibraryStub\MyLibraryStub.csproj]

 

 

I know there is something I’m overlooking. Possibly some attribute I need on MyLibrary or in the project reference in MyLibraryStub.  The question is, why does MSBUILD think the source file is an assembly reference?

Any help or ideas would be greatly appreciated.

 


Mark Howell Display Advertising Platform

Viewing all articles
Browse latest Browse all 2763

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>