【问题标题】:NET CLI tool contains deps.json with development dependency (GitVersion.MsBuild)NET CLI 工具包含具有开发依赖项的 deps.json (GitVersion.MsBuild)
【发布时间】:2021-05-28 00:10:49
【问题描述】:

我正在开发一个 .NET cli 工具。创建的 nuget 包包含一个 deps.json。此 deps.json 文件包含所有引用的 nuget 包的条目。 安装工具dotnet tool install.. 后我无法运行工具dotnet tool run,因为deps.json 文件中列出的程序集丢失

      An assembly specified in the application dependencies manifest (xxxx.deps.json) was not found:
package: 'Microsoft.Win32.SystemEvents', version: '4.7.0'
path: 'runtimes/win/lib/netcoreapp3.0/Microsoft.Win32.SystemEvents.dll'

该包包含runtimes/win/lib/netcoreapp3.0 文件夹但不包含Microsoft.Win32.SystemEvents.dll

问题似乎是 deps.json 中GitVersion.MsBuild 的条目。因为如果我删除此依赖项或删除 deps.json,应用程序将按预期工作。

  • 为什么 deps.json 中包含开发依赖项 <PrivateAssets>all</PrivateAssets>
  • 如何从包中排除 deps.json,这是个好主意吗?

csprj:

    <Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>netcoreapp3.1</TargetFramework>
        <PackAsTool>true</PackAsTool>
        <IncludeBuildOutput>false</IncludeBuildOutput>
        <PackageId>xxxxxxx</PackageId>
        <ToolCommandName>xxxxx</ToolCommandName>
        <PackageOutputPath>..\..\artifacts</PackageOutputPath>
    </PropertyGroup>
    <ItemGroup>
      <PackageReference Include="CommandLineParser" Version="2.8.0" />
        <PackageReference Include="GitVersion.MsBuild" Version="5.6.6">
            <PrivateAssets>all</PrivateAssets>
            <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
        </PackageReference>
      <PackageReference Include="NuGet.ProjectModel" Version="5.8.1" />
    </ItemGroup>
</Project>

deps.json sn-p:

  "GitVersion.MsBuild/5.6.6": {
    "dependencies": {
      "Microsoft.Build.Utilities.Core": "16.8.0"
    }
  },

  // snipp..

  "Microsoft.Win32.SystemEvents/4.7.0": {
    "dependencies": {
      "Microsoft.NETCore.Platforms": "3.1.0"
    },
    "runtimeTargets": {
      "runtimes/win/lib/netcoreapp3.0/Microsoft.Win32.SystemEvents.dll": {
        "rid": "win",
        "assetType": "runtime",
        "assemblyVersion": "4.0.2.0",
        "fileVersion": "4.700.19.56404"
      }
    }
  }

【问题讨论】:

    标签: .net .net-core nuget nuget-package gitversion


    【解决方案1】:

    deps.json 包含所有开发依赖项,对 NET 工具没有意义。 解决办法是完全禁用deps.json文件的生成。

            <GenerateDependencyFile>false</GenerateDependencyFile>
    

    【讨论】:

      猜你喜欢
      • 2018-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-10
      相关资源
      最近更新 更多