MSBuild not copying a DLL, while Visual Studio does
-
10-12-2019 - |
Question
In our Visual Studio 2010 project we reference - among the others - the SmartAssembly.Attributes.dll
and it's properly copied to the Bin/Debug
or Bin/Release
folder of our local dev machines. On the build server this is true for all other references but not for 'SmartAssembly.Attributes.dll'. The build succeeds.
What should I check?
Thanks.
Solution
Open your .csproj
file (or .vbproj
file), and look for the assembly reference. Then make sure the hint path is still valid in your build server. Sometimes VS2010 will add an absolute hint path, instead of using one relative to the .csproj
file itself, so the drive letter may be invalid in another machine.
For example, the reference may look similar to the one below (I made up all of the XML below to illustrate only and it's NOT valid), and the absolute hint path may be invalid in the build server (e.g. there's no drive letter d there):
<Reference
Include="SmartAssembly.Attributes, Version=8.0.0.0,
Culture=neutral, PublicKeyToken=b03f1f7f1ad5da3a,
processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<Private>true<Private>
<!-- The HintPath below should exist and be valid in your build server -->
<HintPath>d:\temp\SmartAssembly.Attributes.dll<HintPath>
</Reference>
You can change the HintPath to make it relative to the .csproj
file and therefore more general. For example:
<HintPath>..\libs\SmartAssembly.Attributes.dll<HintPath>
Another problem may be that <Private>true<Private>
isn't there. This attribute mapped to the CopyLocal
property in Visual Studio, so if it's missing from your .csproj
, the DLL won't get copied to bin\Debug
or bin\Release
by MSBuild. See http://bronumski.blogspot.com/2009/06/project-reference-fun-and-games.html