I have created new project using template ASP.NET Core Web API
in Visual Studio 2022. This is simple API project and have not change anything in the template except in program.cs'; moved out swagger outside the
if (app.Environment.IsDevelopment())so that I can use swagger when deploy application in
Azure App Service'
app.UseSwagger();
app.UseSwaggerUI();
I am using Azure DevOps and getting build error which I need to resolve
error
##[error]C:\Program Files\dotnet\sdk\7.0.200\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(266,5): Error NETSDK1005: Assets file 'D:\a\1\s\MyApp.Web.APIs\obj\project.assets.json' doesn't have a target for 'net7.0'. Ensure that restore has run and that you have included 'net7.0' in the TargetFrameworks for your project.
In project.assets.json
file, I can see TargetFrameworks
is set to 7.0
not really sure, what I am missing from the puzzle.
According to the official documentation, the NuGet version should be higher than 5.8. We got the same error too. What we did was