Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft.Web.Infrastructure is not being built to the bin directory on one of my TFS build servers

This is my error: http://i.imgur.com/hWm3Ta2.png it is resolved by dropping "Microsoft.Web.Infrastructure.dll" into my projects bin directory after it has successfully been built.

I have the same project working on one build server and not the other. My issue is that "Microsoft.Web.Infrastructure.dll" is missing from the bin directory of my project on one build server but not the other after the project is built. Microsoft.Web.Infrastructure reference has its property "Copy Local" set to "True".

Both build servers have TFS and IIS ion them for quick testing/deployment. Clearly the issue is on the build server side but all my research hasnt helped me discover a solution.

Found a more detailed error from my build log:

Primary reference "Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL". c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

and then after this error I get a huge list of places it looked to try and find the DLL but couldnt. I think the fix is as simple as dropping the DLL in any one of those places but I cant help but feel like im fixing this with duct tape. in my /packages/ folder I clearly see the "packages\Microsoft.Web.Infrastructure.1.0.0.0\" directory but there is no lib and no DLL in there. Its as if it is not building.

like image 853
Victorio Berra Avatar asked Jan 20 '14 14:01

Victorio Berra


2 Answers

We had a similar problem. Building and deploying from VS worked but not from our buildmachine with msbuild.exe. Microsoft.Web.Infrastructure.dll has not been copied to the output directory even though the build protocol showed that the file was in the packages directory and recognized by msbuild. The reason was a somewhat corrupt .csproj-file. The project had been updated from VS2015 to VS2017. All went right. The setting "local copy" for the reference "Microsoft.Web.Infrastructure" was set to true according to the UI in VS2017. BUT: When looking at the underlying .csproj-file with a text editor we found two lines missing:

<Reference Include="Microsoft.Web.Infrastructure, ...>
<HintPath>..\packages\...\Microsoft.Web.Infrastructure.dll</HintPath>
<EmbedInteropTypes>False</EmbedInteropTypes>  <-- this line was missing
<Private>True</Private>  <-- this line was missing
</Reference>

Especially the <Private>-tag was crucial since this means "local copy". You can heal that just with setting "Local Copy" to false in VS, saving, then setting back to true. And magically both missing lines will appear and msbuild and you will be happy.

like image 138
Thomas Uttendorfer Avatar answered Oct 17 '22 23:10

Thomas Uttendorfer


I had this same problem. I'm unsure why, in my case TeamCity, did not publish this dll to the bin folder. When I do a local publish it successfully puts it in the deployment.

To fix the problem I added the dll to the GAC on the Windows 2012 servers using GacUtil. A command like the following should work if you have the .net SDK on the server:

gacutil -i "C:\LOCACTION\Microsoft.Web.Infrastructure.dll"
like image 35
Lereveme Avatar answered Oct 17 '22 22:10

Lereveme