1
votes

I've been successfully deploying an ASP.Net MVC Azure-based website via Visual Studio Online's build pipeline for weeks. I then added an ApiController class and Visual Studio installed some related NuGet packages. Now, when I check in and the build starts, I get failures due to a missing System.Web.Http dll.

I have tried reinstalling the NuGet package and also marking the missing dlls as 'Copy Local'. Still no joy.

The Build step first reports a warning:

C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets (1819, 5) Could not resolve this reference. Could not locate the assembly "System.Web.Http, Version=5.2.3.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.

It then reports a number of errors and fails:

[Solution Name][Website Name]\App_Start\WebApiConfig.cs (1, 18) The type or namespace name 'Http' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)

I am using Visual Studio 2015 RC and .Net 4.6 (although dropping down to v4.5.2 still produces the error).

For now I have to manually Publish this. Anyone got any ideas please?

2
With a bit more investigation I can now see that the NuGet.exe restore command is ignoring some packages listed in the packages.config. Why would it do this? - Chris Arnold
When you build it locally within Visual Studio is the .DLL in the bin folder for System.Web.Http? - Luke
@ChrisArnold, are you using vNext build? If so, check my reply below. - Vicky - MSFT

2 Answers

1
votes

Firstly, be sure the followings can be found in the .proj file:

<Reference Include="System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <HintPath>..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll</HintPath>
  <Private>True</Private>
</Reference>

Secondly, check the Restore NuGet Packages checkbox in the Visual Studio Build step. (Assuming you're using build vNext) enter image description here

0
votes

I found that Visual Studio Online was looking for the nuget package reference from the source code repository. I was able to get around these errors by checking in the missing dlls.

For example:

\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll