Errors in Azure DevOps build - are you missing an assembly reference?

回眸只為那壹抹淺笑 提交于 2021-02-18 20:58:56

问题


I am using VSTS (Azure DevOps) for the first time and am setting up my first build (I have previously been using TFS). I'm trying to build a .NET application targeting .NET Framework 4.6.

However I'm getting build errors relating to missing namespaces and / or assemblies.

Error CS0246: The type or namespace name 'OwinStartupAttribute' could not be found (are you missing a using directive or an assembly reference?)

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

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

The issues all seem to be related i.e. the nuget packages aren't getting restored during the build process.

I've therefore added a Nuget restore task to the pipeline before my build step.

And have checked the option Restore Nuget packages on the build step.


回答1:


I managed to get this working as I had some of the Nuget packages checked-in as part of source-control. I removed the entire packages folder from the solution and this has resolved the issue. There must have been some conflict between the packages I had in source-control and the packages I was trying to restore.




回答2:


In my case, this would happen because, for some reason, the local cache was only partially populated. Disabling the local cache in the build definition fixed the issue.




回答3:


I had some projects in a large solution with this problem; they had the old "packages.config" files. To fix, In Solution Explorer, right-click on a packages.config file and select Migrate packages.config to PackageReference.

Docs.



来源:https://stackoverflow.com/questions/52383814/errors-in-azure-devops-build-are-you-missing-an-assembly-reference

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!