微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

NET CLI 工具包含具有开发依赖项的 deps.json (GitVersion.MsBuild)

如何解决NET CLI 工具包含具有开发依赖项的 deps.json (GitVersion.MsBuild)

我正在开发一个 .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

enter image description here

问题似乎出在 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 片段:

  "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"
      }
    }
  }

解决方法

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

        <GenerateDependencyFile>false</GenerateDependencyFile>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?