The Nuget Restore from VSO's build pipeline failed due to some nuget packages that are not compatible with netcoreapp2.1. However, when I looked through all the csproj files in the solution, none of the csproj files have these nuget packages. I might have installed these before but right now it's definitely not here.
Here's the csproj file that is mentioned in the error message.
<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi" Version="5.2.6" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
</ItemGroup>
Here's the Nuget.Config file
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
</configuration>
Please advise how to fix this issue.
EDIT=====================================================
After removing the nuget package from Microsoft.AspNet.WebApi, the NugetRestore passed, but Build solution failed. It shows a different error
[error]C:\Program Files\dotnet\sdk\2.2.104\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(208,5):
Error NETSDK1004: Assets file
'd:\agentwrok\18\s....\obj\project.assets.json' not found. Run a
NuGet package restore to generate this file.
This is the configuration for Build Solution
Any advice on the next step?
VSO Build Pipeline's Nuget Restore Failed
Just like Volodymyr commented, you should not use the package Microsoft.AspNet.WebApi for the .net core project. That is because this package is targeted at .NETFramework, not .NET Core/.NETStandard. It is not compatible with .NET Core.
When you check the package Microsoft.AspNet.WebApi on nuget.org, you will notice that this package has a dependency on Microsoft.AspNet.WebApi.WebHost, which only targets the .NET Framework:
And the sub-dependency Microsoft.AspNet.WebApi.Core of the package Microsoft.AspNet.WebApi.WebHost also only targets the .NET Framework:
So, the reason for this issue is that the package Microsoft.AspNet.WebApi and its dependencies are not compatible with .NET Core framework.
Hope this helps.
Related
Upgrading from .NET 5 to .NET 6 is proving not so straightforward as I expected.
All my unit test projects fail to compile due to the following error
Severity Code Description Project File Line Suppression State
Error CS0433 The type 'ServiceCollection' exists in both 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' and 'Microsoft.Extensions.DependencyInjection, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' Sample.DynamoDb.FunctionalTests C:\src\my-solution\test\Sample.DynamoDb.FunctionalTests\DependencyInjectionTests\GetServiceTests.cs 22 Active
They reference class libraries that depend on Microsoft.Extensions.DependencyInjection.Abstractions version 6
but for some reason it seems there is a dependency on Microsoft.Extensions.DependencyInjection in the test project itself. Probably dragged across by some of the packages I use (and I don't know which one).
This is my test project
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>Enable</Nullable>
<IsPackable>False</IsPackable>
<IsPublishable>False</IsPublishable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Sample.DynamoDb.DependencyInjection\Sample.DynamoDb.DependencyInjection.csproj" />
</ItemGroup>
</Project>
Anyone with a similar problem or an idea on how to troubleshoot and find the issue or a workaround?
It turns out the problem was because some referenced project, referenced another, that referenced another... that had a nuget dependency EventStore.Client.Grpc that depends, itself, on Microsoft.Extensions.Logging 5.0.0
And that Microsoft.Extensions.Logging bring the subdependency Microsoft.Extensions.DependencyInjection 5.0.0
Having a look at my test project's obj/project.assets.json helped me trace that.
My solution builds perfectly on my local machine and it uses Microsoft.Data.Sqlclient and Azure.Core nuget packages, but the solution does NOT build on our Azure Devops server because there is no internet access there. The error is "Error NETSDK1064: Package Azure.Core, version 1.20.0 was not found."
I put these packages in a .packages subfolder and created a Nuget.config file that I believe references this sub-folder, but no luck.
How can I tell our DevOps server to use find the Nuget packages in the .packages subfolder?
I finally got this to work through the NuGet Restore task placed before the build. I chose "custom" as the NuGet Restore command type, and the actual command was:
restore CoreBZ2.sln -PackagesDirectory ..\packages
with ALL of the needed packages (all .nupkg files) in the "packages" subfolder of my solution. (CoreBZ2.sln is the name of my project/solution.)
I also had a NuGet.config file placed in the same folder as the solution and it looked like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value=".\packages" />
<add key="Azure.Core" value=".\packages" />
</packageSources>
<config>
<add key="globalPackagesFolder" value=".\packages" />
<add key="defaultPushSource" value=".\packages" />
</config>
<activePackageSource>
<add key="All" value=".\packages" />
</activePackageSource>
<config>
<add key="repositoryPath" value="$\..\packages" />
</config>
</configuration>
There is probably a better way to do this, but this did finally result in a successful build on the offline DevOps server.
I am trying to host an ASP.NET Core 3.0 API in Azure:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<IsPackable>false</IsPackable>
<NeutralLanguage>en-US</NeutralLanguage>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="3.*" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.*" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.*" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="3.*" />
</ItemGroup>
</Project>
But when I run de application I get:
HTTP Error 500.31 - ANCM Failed to Find Native Dependencies
Common solutions to this issue:
The specified version of Microsoft.NetCore.App or Microsoft.AspNetCore.App was not found.
Specific error detected by ANCM:
It was not possible to find any compatible framework version The specified framework 'Microsoft.AspNetCore.App', version '3.0.0' was not found. - The following frameworks were found: 2.1.12 at [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App] 2.1.13 at [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App] 2.2.6 at [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App] 2.2.7 at [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App] You can resolve the problem by installing the specified framework and/or SDK. The .NET Core frameworks can be found at: - https://aka.ms/dotnet-download
What am I missing?
The current picture is that ASP.NET Core 3.0 is available everywhere (but not the SDK).
Despite this fact, I (seemingly randomly) got a
HTTP Error 500.31 - ANCM Failed to Find Native Dependencies
until I realized that activating logging in web.config by setting stdoutLogEnabled to true without adjusting the stdoutLogFile to \\?\%home%\LogFiles\stdout (as suggested in Troubleshoot ASP.NET Core on Azure App Service and IIS) was the cause of this error message.
Took me some hours to realize this causality.
ASP.NET Core 3.0 not currently available for Azure App Service. [Microsoft Docs]
The preview versions of .NET Core 3.0 [Microsoft Docs] are available on the Azure service.
Change this in web.config:
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
to this:
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
I removed V2 from this modules="AspNetCoreModuleV2" and it works.
I'm getting an issue with deploying via git to Azure. My app called Blogg keeps getting hung up when the PostCompile command runs after the app gets published to the server. That command is:
<Exec Command="dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" />
I was under the impression that the package reference for this command came from Microsoft.AspNetCore.Server.IISIntegration but even after adding versions 1.1.0-preview4-final and 1.1.2 (the latest), I'm still having troubles.
In case it's helpful, below are what's in my .csproj file:
`<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="1.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.1.0-preview4-final" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.0.2" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.0.1" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Session" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.sqlserver.Design" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.0.0-msbuild2-final" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0-msbuild2-final" />
</ItemGroup>
<ItemGroup>
<None Include="wwwroot/*" CopyToPublishDirectory="Always" />
<None Include="Views/*" CopyToPublishDirectory="Always" />
<None Include="web.config" CopyToPublishDirectory="Always" />
</ItemGroup>
<Target Name="MyPostCompileTarget" AfterTargets="Publish">
<Exec Command="dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" />
</Target>
</Project>`
And the error I'm getting from the Azure log:
`Command: "D:\home\site\deployments\tools\deploy.cmd"
Handling ASP.NET Core Web Application deployment.
Restoring packages for D:\home\site\repository\Blogg.csproj...
D:\Program Files (x86)\dotnet\sdk\1.0.0-rc4-004771\NuGet.targets(97,5): warning : Dependency specified was Microsoft.AspNetCore.Server.IISIntegration (>= 1.1.0-preview4-final) but ended up with Microsoft.AspNetCore.Server.IISIntegration 1.1.0. [D:\home\site\repository\Blogg.csproj]
Installing Microsoft.AspNetCore.Http.Features 1.1.0.
Installing Microsoft.AspNetCore.Hosting.Server.Abstractions 1.1.0.
Installing Microsoft.Extensions.Configuration.Abstractions 1.1.0.
Installing Microsoft.AspNetCore.Http.Abstractions 1.1.0.
Installing Microsoft.AspNetCore.WebUtilities 1.1.0.
Installing Microsoft.Extensions.ObjectPool 1.1.0.
Installing Microsoft.Net.Http.Headers 1.1.0.
Installing Microsoft.AspNetCore.Http.Extensions 1.1.0.
Installing Microsoft.AspNetCore.Hosting.Abstractions 1.1.0.
Installing Microsoft.AspNetCore.Http 1.1.0.
Installing Microsoft.Extensions.Logging.Abstractions 1.1.0.
Installing Microsoft.Extensions.Options 1.1.0.
Installing Microsoft.AspNetCore.HttpOverrides 1.1.0.
Installing Microsoft.AspNetCore.Server.IISIntegration 1.1.0.
Writing lock file to disk. Path: D:\home\site\repository\obj\project.assets.json
Restore completed in 18.69 sec for D:\home\site\repository\Blogg.csproj.
Restoring packages for D:\home\site\repository\Blogg.csproj...
Restore completed in 14.38 sec for D:\home\site\repository\Blogg.csproj.
Restoring packages for D:\home\site\repository\Blogg.csproj...
Restore completed in 17.49 sec for D:\home\site\repository\Blogg.csproj.
NuGet Config files used:
D:\local\AppData\NuGet\NuGet.Config
Feeds used:
https://api.nuget.org/v3/index.json
Installed:
14 package(s) to D:\home\site\repository\Blogg.csproj
Microsoft (R) Build Engine version 15.1.545.13942
Copyright (C) Microsoft Corporation. All rights reserved.
Blogg -> D:\home\site\repository\bin\Release\netcoreapp1.0\Blogg.dll
No executable found matching command "dotnet-publish-iis"
D:\home\site\repository\Blogg.csproj(30,5): error MSB3073: The command "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" exited with code 1.
Failed exitCode=1, command=dotnet publish "D:\home\site\repository\Blogg.csproj" --output "D:\local\Temp\8d4ac97ca692979" --configuration Release
An error has occurred during web site deployment.
\r\nD:\Program Files (x86)\SiteExtensions\Kudu\62.60524.2862\bin\Scripts\starter.cmd "D:\home\site\deployments\tools\deploy.cmd"`
When using csproj files for ASP.NET Core web applications, you can safely remove this line:
<Exec Command="dotnet publish-iis …" />
For project.json based projects, this command performed actions that are now performed by default if your project uses the web sdk:
<Project Sdk="Microsoft.NET.Sdk.Web">
It looks like the migration correctly removed the tools reference to the dotnet-publish-iis tool but did not remove the corresponding invocation. You could file an issue at the dotnet migrate tool's GitHub repository with your original project.json file.
I'm using nuget integration with msbuild (visual studio 2012) to automatically restore broken packages. Below you can see my .nuget/nuget.config file for solution:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageRestore>
<add key="enabled" value="True" />
</packageRestore>
<disabledPackageSources />
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
<config>
<add key="repositoryPath" value="..\..\Lib\NuGet\Packages" />
</config>
</configuration>
My packages directory moved outside from solution. This works fine during build, but Package Manager Console still using $(SolutionDir)\packages to install (and restore) packages.
It is possible to change packages directory for "Package Manager Console"?
nuget.config
You got the first part:
<config>
<add key="repositoryPath" value="..\MySuperCoolPackages" />
</config>
But you have to tell the command line about the nuget.config file explicitly.
C:\SomeFolder\NuGet.exe install "C:\MySolution\.nuget\packages.config" -ConfigFile "C:\MySolution\.nuget\nuget.config"
When you create nuget.config with repositoryPath you need to restart VS for it to be reread and console to be aware of it.
Edit: #DmitryBykadorov weird, may be your nuget is out of date? There was an early problem where due to config being in .nuget subfolder and not in .csproj's current>parent>parent>etc path it wouldn't see it and required one nuget.config with restore info and one (typically next to .sln or .csproj itself) with repositoryPath, but my VS2012 with whatever latest nuget it comes with works fine with config below. May be your global nuget config somehow affects it, or your solution needs hard clean/rebuild?
<configuration>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
<config>
<add key="repositoryPath" value="..\..\lib" />
</config>
</configuration>