NU1100:无法解析“.NETStandard,Version=v1.3”的 'System.Reflection.TypeExtensions (>= 4.5.1)'
NU1100: Unable to resolve 'System.Reflection.TypeExtensions (>= 4.5.1)' for '.NETStandard,Version=v1.3'
我正在尝试 to migrate my small OSS project from AppVeyor to Azure DevOps and got almost everything done but now getting this error dotnet restore
步骤:
NU1100: Unable to resolve 'System.Reflection.TypeExtensions (>= 4.5.1)' for '.NETStandard,Version=v1.3'.
尽管我清楚地看到 System.Reflection.TypeExtensions 支持 .NET Standard 1.3:
.NETStandard 1.3
System.Reflection (>= 4.3.0)
System.Resources.ResourceManager (>= 4.3.0)
System.Runtime (>= 4.3.0)
我做错了什么?
更新: my YAML file 看起来像这样:
trigger:
- master
pool:
vmImage: 'windows-2019'
variables:
solution: 'JWT.sln'
buildConfiguration: 'Release'
buildPlatform: 'Any CPU'
dotNetVersion: '2.2.106'
steps:
- task: DotNetCoreInstaller@0
displayName: Install .NET Core v$(dotNetVersion)
inputs:
version: $(dotNetVersion)
- task: DotNetCoreCLI@2
displayName: 'Restore NuGet packages'
inputs:
command: 'restore'
projects: '**/*.csproj'
feedsToUse: config
nugetConfigPath: NuGet.config
- task: DotNetCoreCLI@2
displayName: 'Build solution'
inputs:
command: 'build'
projects: '$(solution)'
configuration: '$(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: Run .NET Core tests
inputs:
command: 'test'
projects: 'tests/**/JWT.Tests.Core.csproj'
arguments: ' -c $(buildConfiguration) --no-build --no-restore'
testRunner: VSTest
testResultsFiles: '**/*.trx'
testResultsFormat: 'xUnit'
failTaskOnFailedTests: true
- task: DotNetCoreCLI@2
displayName: Run .NET Framework tests
inputs:
command: 'test'
projects: 'tests/**/JWT.Tests.NetFramework.csproj'
arguments: ' -c $(buildConfiguration) --no-build --no-restore'
testRunner: VSTest
testResultsFiles: '**/*.trx'
testResultsFormat: 'xUnit'
failTaskOnFailedTests: true
- task: DotNetCoreCLI@2
displayName: Package NuGet package
inputs:
command: pack
packagesToPack: 'src/**/*.csproj'
configuration: $(BuildConfiguration)
nobuild: true
- task: PublishBuildArtifacts@1
displayName: Publish build artifacts
更新 2: 我尝试分别恢复 .NET Core 和 .NET Framework 的包,但没有成功:
displayName: 'Restore NuGet packages for .NET Core'
inputs:
command: 'restore'
projects: '**/*.csproj'
feedsToUse: config
nugetConfigPath: NuGet.config
- task: NuGetCommand@2
displayName: 'Restore NuGet packages for .NET Framework'
inputs:
command: 'restore'
restoreSolution: $(solution)
feedsToUse: config
nugetConfigPath: NuGet.config
- task: DotNetCoreCLI@2
displayName: 'Build solution'
inputs:
command: 'build'
projects: '$(solution)'
configuration: '$(buildConfiguration)'
但有效的是显式恢复包的原始 MSBuild:
- task: MSBuild@1
displayName: Build solution
inputs:
solution: $(solution)
msbuildArguments: /restore /t:build /p:CreatePackage=true /p:NoPackageAnalysis=true /p:PackageOutputPath=$(Build.ArtifactStagingDirectory)\artifacts
configuration: $(BuildConfiguration)
maximumCpuCount: true
我认为您的 dotnet 恢复任务不是 dotnet 恢复,而是 msbuild / NuGet 恢复?
特别是,从日志的最后 20 行来看,我假设这个错误与这个包无关,只是这个包是它尝试恢复的第一个包,所以这是它所在的位置出错了,真正的问题更多是 https://github.com/NuGet/Home/issues/4821 之类的变体。
诊断步骤 1:将构建代理容器更改为没有 visual studio 的容器,看看是否修复了还原错误。
我确信 (1) 恢复步骤对于 dotnet 核心工具链是多余的,并且 (2) 您必须使用 dotnet 核心工具链在您的开发桌面上构建?
所以我认为迁移到 Azure 的问题可能是,(1) 如何构建正确的管道并不明显,以及 (2) dotnet core/msbuild/nuget 交互中可能存在一些错误。
- 如果您使用 GUI 选项,那么您想要的 只有 个任务是
dotnet core
个任务
- 如果您使用 YML 选项,则首先选择 仅 从 https://docs.microsoft.com/en-us/azure/devops/pipelines/languages/dotnet-core 中提取的片段。该页面上的代码片段等同于 运行 本地计算机上的 dotnet 命令,因此可以在本地计算机上进行一些调试。
这是我的结局 having working:
trigger:
- master
pool:
vmImage: 'windows-2019'
variables:
solution: 'JWT.sln'
buildConfiguration: 'Release'
buildPlatform: 'Any CPU'
coreVersion: '2.2.106'
nugetVersion: '4.9.4'
steps:
- task: DotNetCoreInstaller@0
displayName: Install .NET Core v$(coreVersion)
inputs:
version: $(coreVersion)
- task: DotNetCoreCLI@2
displayName: 'Restore NuGet packages for .NET Core'
inputs:
command: 'restore'
projects: '**/*.csproj'
- task: NuGetToolInstaller@0
displayName: Install NuGet v$(nugetVersion)
inputs:
versionSpec: $(nugetVersion)
checkLatest: true
- task: NuGetCommand@2
displayName: 'Restore NuGet packages for .NET Framework'
inputs:
command: 'restore'
restoreSolution: $(solution)
- task: DotNetCoreCLI@2
displayName: 'Build solution'
inputs:
command: 'build'
projects: '$(solution)'
arguments: '-c $(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: Run .NET Core tests
inputs:
command: 'test'
projects: 'tests/**/JWT.Tests.Core.csproj'
arguments: ' -c $(buildConfiguration) --no-build --no-restore'
testRunner: VSTest
testResultsFiles: '**/*.trx'
testResultsFormat: 'xUnit'
failTaskOnFailedTests: true
- task: DotNetCoreCLI@2
displayName: Run .NET Framework tests
inputs:
command: 'test'
projects: 'tests/**/JWT.Tests.NetFramework.csproj'
arguments: ' -c $(buildConfiguration) --no-build --no-restore'
testRunner: VSTest
testResultsFiles: '**/*.trx'
testResultsFormat: 'xUnit'
failTaskOnFailedTests: true
- task: DotNetCoreCLI@2
displayName: Package NuGet package
inputs:
command: pack
packagesToPack: 'src/**/*.csproj'
configuration: $(BuildConfiguration)
nobuild: true
- task: PublishBuildArtifacts@1
displayName: Publish build artifacts
我正在尝试 to migrate my small OSS project from AppVeyor to Azure DevOps and got almost everything done but now getting this error dotnet restore
步骤:
NU1100: Unable to resolve 'System.Reflection.TypeExtensions (>= 4.5.1)' for '.NETStandard,Version=v1.3'.
尽管我清楚地看到 System.Reflection.TypeExtensions 支持 .NET Standard 1.3:
.NETStandard 1.3
System.Reflection (>= 4.3.0)
System.Resources.ResourceManager (>= 4.3.0)
System.Runtime (>= 4.3.0)
我做错了什么?
更新: my YAML file 看起来像这样:
trigger:
- master
pool:
vmImage: 'windows-2019'
variables:
solution: 'JWT.sln'
buildConfiguration: 'Release'
buildPlatform: 'Any CPU'
dotNetVersion: '2.2.106'
steps:
- task: DotNetCoreInstaller@0
displayName: Install .NET Core v$(dotNetVersion)
inputs:
version: $(dotNetVersion)
- task: DotNetCoreCLI@2
displayName: 'Restore NuGet packages'
inputs:
command: 'restore'
projects: '**/*.csproj'
feedsToUse: config
nugetConfigPath: NuGet.config
- task: DotNetCoreCLI@2
displayName: 'Build solution'
inputs:
command: 'build'
projects: '$(solution)'
configuration: '$(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: Run .NET Core tests
inputs:
command: 'test'
projects: 'tests/**/JWT.Tests.Core.csproj'
arguments: ' -c $(buildConfiguration) --no-build --no-restore'
testRunner: VSTest
testResultsFiles: '**/*.trx'
testResultsFormat: 'xUnit'
failTaskOnFailedTests: true
- task: DotNetCoreCLI@2
displayName: Run .NET Framework tests
inputs:
command: 'test'
projects: 'tests/**/JWT.Tests.NetFramework.csproj'
arguments: ' -c $(buildConfiguration) --no-build --no-restore'
testRunner: VSTest
testResultsFiles: '**/*.trx'
testResultsFormat: 'xUnit'
failTaskOnFailedTests: true
- task: DotNetCoreCLI@2
displayName: Package NuGet package
inputs:
command: pack
packagesToPack: 'src/**/*.csproj'
configuration: $(BuildConfiguration)
nobuild: true
- task: PublishBuildArtifacts@1
displayName: Publish build artifacts
更新 2: 我尝试分别恢复 .NET Core 和 .NET Framework 的包,但没有成功:
displayName: 'Restore NuGet packages for .NET Core'
inputs:
command: 'restore'
projects: '**/*.csproj'
feedsToUse: config
nugetConfigPath: NuGet.config
- task: NuGetCommand@2
displayName: 'Restore NuGet packages for .NET Framework'
inputs:
command: 'restore'
restoreSolution: $(solution)
feedsToUse: config
nugetConfigPath: NuGet.config
- task: DotNetCoreCLI@2
displayName: 'Build solution'
inputs:
command: 'build'
projects: '$(solution)'
configuration: '$(buildConfiguration)'
但有效的是显式恢复包的原始 MSBuild:
- task: MSBuild@1
displayName: Build solution
inputs:
solution: $(solution)
msbuildArguments: /restore /t:build /p:CreatePackage=true /p:NoPackageAnalysis=true /p:PackageOutputPath=$(Build.ArtifactStagingDirectory)\artifacts
configuration: $(BuildConfiguration)
maximumCpuCount: true
我认为您的 dotnet 恢复任务不是 dotnet 恢复,而是 msbuild / NuGet 恢复?
特别是,从日志的最后 20 行来看,我假设这个错误与这个包无关,只是这个包是它尝试恢复的第一个包,所以这是它所在的位置出错了,真正的问题更多是 https://github.com/NuGet/Home/issues/4821 之类的变体。
诊断步骤 1:将构建代理容器更改为没有 visual studio 的容器,看看是否修复了还原错误。
我确信 (1) 恢复步骤对于 dotnet 核心工具链是多余的,并且 (2) 您必须使用 dotnet 核心工具链在您的开发桌面上构建?
所以我认为迁移到 Azure 的问题可能是,(1) 如何构建正确的管道并不明显,以及 (2) dotnet core/msbuild/nuget 交互中可能存在一些错误。
- 如果您使用 GUI 选项,那么您想要的 只有 个任务是
dotnet core
个任务 - 如果您使用 YML 选项,则首先选择 仅 从 https://docs.microsoft.com/en-us/azure/devops/pipelines/languages/dotnet-core 中提取的片段。该页面上的代码片段等同于 运行 本地计算机上的 dotnet 命令,因此可以在本地计算机上进行一些调试。
这是我的结局 having working:
trigger:
- master
pool:
vmImage: 'windows-2019'
variables:
solution: 'JWT.sln'
buildConfiguration: 'Release'
buildPlatform: 'Any CPU'
coreVersion: '2.2.106'
nugetVersion: '4.9.4'
steps:
- task: DotNetCoreInstaller@0
displayName: Install .NET Core v$(coreVersion)
inputs:
version: $(coreVersion)
- task: DotNetCoreCLI@2
displayName: 'Restore NuGet packages for .NET Core'
inputs:
command: 'restore'
projects: '**/*.csproj'
- task: NuGetToolInstaller@0
displayName: Install NuGet v$(nugetVersion)
inputs:
versionSpec: $(nugetVersion)
checkLatest: true
- task: NuGetCommand@2
displayName: 'Restore NuGet packages for .NET Framework'
inputs:
command: 'restore'
restoreSolution: $(solution)
- task: DotNetCoreCLI@2
displayName: 'Build solution'
inputs:
command: 'build'
projects: '$(solution)'
arguments: '-c $(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: Run .NET Core tests
inputs:
command: 'test'
projects: 'tests/**/JWT.Tests.Core.csproj'
arguments: ' -c $(buildConfiguration) --no-build --no-restore'
testRunner: VSTest
testResultsFiles: '**/*.trx'
testResultsFormat: 'xUnit'
failTaskOnFailedTests: true
- task: DotNetCoreCLI@2
displayName: Run .NET Framework tests
inputs:
command: 'test'
projects: 'tests/**/JWT.Tests.NetFramework.csproj'
arguments: ' -c $(buildConfiguration) --no-build --no-restore'
testRunner: VSTest
testResultsFiles: '**/*.trx'
testResultsFormat: 'xUnit'
failTaskOnFailedTests: true
- task: DotNetCoreCLI@2
displayName: Package NuGet package
inputs:
command: pack
packagesToPack: 'src/**/*.csproj'
configuration: $(BuildConfiguration)
nobuild: true
- task: PublishBuildArtifacts@1
displayName: Publish build artifacts