Reputation: 15455
Given:
New to Azure Builds
I have a simple WebApi project that uses Swashbuckle.AspNetCore. Everything works fine locally (of course) but when I try to build in Azure builds I get the following error:
The type or namespace name 'OpenApi' does not exist in the namespace 'Microsoft'
I added the SwashBuckle and OpenApi NuGet packages to Azure Artifacts
and referenced that in my build script.
- task: NuGetCommand@2
inputs:
command: 'restore'
restoreSolution: '**/*.sln'
feedsToUse: 'select'
vstsFeed: '/12b2f6b8-fb61-4aac-a526-27a85a46a5b4'
/reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\3.1.0\ref\netcoreapp3.1\System.Xml.XPath.XDocument.dll" /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\3.1.0\ref\netcoreapp3.1\WindowsBase.dll" /debug+ /debug:portable /filealign:512 /optimize+ /out:obj\Release\netcoreapp3.1\ApiApplication1.dll /target:exe /warnaserror- /utf8output /deterministic+ /analyzer:"C:\Program Files\dotnet\sdk\3.1.202\Sdks\Microsoft.NET.Sdk.Web\analyzers\cs\Microsoft.AspNetCore.Analyzers.dll" /analyzer:"C:\Program Files\dotnet\sdk\3.1.202\Sdks\Microsoft.NET.Sdk.Web\analyzers\cs\Microsoft.AspNetCore.Mvc.Analyzers.dll" /analyzer:"C:\Program Files\dotnet\sdk\3.1.202\Sdks\Microsoft.NET.Sdk.Web\analyzers\cs\Microsoft.AspNetCore.Components.Analyzers.dll" Controllers\WeatherForecastController.cs Program.cs Startup.cs WeatherForecast.cs "C:\Users\rodneysantiago\AppData\Local\Temp.NETCoreApp,Version=v3.1.AssemblyAttributes.cs" obj\Release\netcoreapp3.1\ApiApplication1.AssemblyInfo.cs /warnaserror+:NU1605 Using shared compilation with compiler from directory: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\Roslyn
Startup.cs(12,17): error CS0234: The type or namespace name 'OpenApi' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [C:\agent2_work\2\s\RsWpfAndApiSolution\ApiApplication1\ApiApplication1.csproj] Done Building Project "C:\agent2_work\2\s\RsWpfAndApiSolution\ApiApplication1\ApiApplication1.csproj" (default targets) -- FAILED. Done Building Project "C:\agent2_work\2\s\RsWpfAndApiSolution\RsWpfAndApiSolution.sln" (default targets) -- FAILED.
Build FAILED.
Upvotes: 3
Views: 4869
Reputation: 295
Uninstall Swashbuckle.AspNetCore and reinstall with the latest version of the same package to resolve this error. Unfortunately VS doesn't show this error but its caught in CI/CD or when you run in Command Line.
Upvotes: 2