Poul K. Sørensen
Poul K. Sørensen

Reputation: 17530

The type 'HttpRequestMessage' is defined in an assembly that is not referenced

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" />

Upvotes: 2

Views: 2133

Answers (1)

Cece Dong - MSFT
Cece Dong - MSFT

Reputation: 31003

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.

Upvotes: 2

Related Questions