2

I've got MVC.Net application in my TFS2015. My Applications builds & runs fine in Local. I'm configuring CI/Cd pipeline for this application. Please find the error specified below

Error CS0234: The type or namespace name 'WebApi' does not exist in the namespace 'Microsoft.AspNet' (are you missing an assembly reference?)

Error CS0234: The type or namespace name 'Extensions' does not exist in the namespace 'System.Net.Http' (are you missing an assembly reference?)

I've tried both MSBUILD & Visual Studio Build tasks in my pipeline, still same error occurs enter image description here

enter image description here

Shalem
  • 1,446
  • 2
  • 22
  • 47

2 Answers2

2

The type or namespace name 'WebApi' does not exist in the namespace 'Microsoft.AspNet' (are you missing an assembly reference?)

According to the error message, it seems you are missing the references when you build with Azure DevOps. You should add nuget installer tasks to restore the package:

NuGet Tool Installer task

When we build the project/solution on local machine, the packages is downloaded stored in the \packages folder, this folder is ignored by the source control (This is recommended.) when we submit our source code, so when we build the project/solution on the Azure DevOps, we need add nuget restore task to restore nuget package before we build it.

If you have already use nuget restore in your pipeline and still get that error, please share the warning info in your build log.

Hope this helps.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135
  • My Build pipeline already consists of Nuget installer Task, which should restore Nuget packages. Please find the screenshot appended. – Shalem Apr 04 '19 at 05:44
  • @Shalem, you can post the error log in your question or share it by one-drive. Besides, I just only see you have add the nuget installer task, not add nuget restore task. – Leo Liu Apr 04 '19 at 06:14
  • @Shalem, I already added the screenshot in my answer, please check the second image. Search nuget in the marketplace and add the nuget, which you can select restore after you add the nuget task. – Leo Liu Apr 04 '19 at 06:19
  • I'm implementing CI in TFS2015 [On-Premise] and am not able to find Restore Nuget for this even in Market place. But, my Visual Studio Build task has got Restore Nuget option which i'm already using. Can you suggest on this please – Shalem Apr 04 '19 at 06:39
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/191209/discussion-between-shalem-and-leo-liu-msft). – Shalem Apr 04 '19 at 06:41
2

I've copied the missing dll's from

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2\Facades

To

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2

Thanks @Leo Liu -MSFT for suggesting this article. It worked for me

Shalem
  • 1,446
  • 2
  • 22
  • 47