豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

GetRestoreDotnetCliToolsTask fails when missing version metadata #5716

@natemcmaster

Description

@natemcmaster

When a PackageReference is missing "Version", it fails gracefully with something like

warning NU1604: Project dependency xunit does not contain an inclusive lower bound. Include a lower bound in the dependency version to ensure consistent restore results.

When DotNetCliToolReference is missing "Version", it fails completely with an ArgumentNullException. This breaks our ability to use the /t:GenerateRestoreGraphFile target to example a repo's restore graph for issues.

Repro

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
     <DotNetCliToolReference Include="dotnet-xunit" />
  </ItemGroup>

</Project>

dotnet restore

Result

C:\Users\namc\.dotnet\x64\sdk\2.0.0-preview3-006915\NuGet.targets(331,5): error MSB4018: The "GetRestoreDotnetCliToolsTask" task failed unexpectedly.\r [C:\tmp\tst\classlib1\tst.csproj]
System.ArgumentNullException: Value cannot be null.\r [C:\tmp\tst\classlib1\tst.csproj]
Parameter name: value\r [C:\tmp\tst\classlib1\tst.csproj]
    at NuGet.Versioning.VersionRange.TryParse(String value, Boolean allowFloating, VersionRange& versionRange)\r [C:\tmp\tst\classlib1\tst.csproj]
    at NuGet.Versioning.VersionRange.Parse(String value, Boolean allowFloating)\r [C:\tmp\tst\classlib1\tst.csproj]
    at NuGet.Build.Tasks.GetRestoreDotnetCliToolsTask.Execute()\r [C:\tmp\tst\classlib1\tst.csproj]
    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()\r [C:\tmp\tst\classlib1\tst.csproj]
    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__25.MoveNext() [C:\tmp\tst\classlib1\tst.csproj]

Details

NuGet product used: dotnet.exe
dotnet.exe --version: 2.0.0-preview3-006915

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions