2

When i build locally it works, but my VSTS hosted 2017 instance build fails with the following message:

[error]apps\Ascend.Identity\AccountController.cs(126,17): Error CS0012: The type 'HttpRequestMessage' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

Locally, there is also a yellow triangle in the reference list. enter image description here

but it still builds

and the reference is there in csproj

enter image description here

and the package is restored from nuget (packages.config)

 <package id="System.Net.Http" version="4.3.3" targetFramework="net472" />
Poul K. Sørensen
  • 16,950
  • 21
  • 126
  • 283

1 Answers1

2

In your local, try the steps below:

  1. Delete packages folder in your source directory.
  2. Remove System.Net.Http reference.
  3. Right click References, select Manage Nuget Packages, browser and install package System.Net.Http.
  4. Build your project and check the result. Make sure there is no yellow triangle in the reference list.
  5. Check in the changes and queue a build.
Cece Dong - MSFT
  • 29,631
  • 1
  • 24
  • 39
  • similar issue, I solved by following this thread https://github.com/dotnet/runtime/issues/26131#issuecomment-396753264 – cwhsu Nov 21 '20 at 12:46