• <i id='v55RE'><tr id='v55RE'><dt id='v55RE'><q id='v55RE'><span id='v55RE'><b id='v55RE'><form id='v55RE'><ins id='v55RE'></ins><ul id='v55RE'></ul><sub id='v55RE'></sub></form><legend id='v55RE'></legend><bdo id='v55RE'><pre id='v55RE'><center id='v55RE'></center></pre></bdo></b><th id='v55RE'></th></span></q></dt></tr></i><div id='v55RE'><tfoot id='v55RE'></tfoot><dl id='v55RE'><fieldset id='v55RE'></fieldset></dl></div>
      <legend id='v55RE'><style id='v55RE'><dir id='v55RE'><q id='v55RE'></q></dir></style></legend>

      <small id='v55RE'></small><noframes id='v55RE'>

      <tfoot id='v55RE'></tfoot>
          <bdo id='v55RE'></bdo><ul id='v55RE'></ul>
      1. NuGet 包显示没有依赖项?

        时间:2023-05-21

            <tbody id='leruA'></tbody>

          <small id='leruA'></small><noframes id='leruA'>

          <tfoot id='leruA'></tfoot>

            <legend id='leruA'><style id='leruA'><dir id='leruA'><q id='leruA'></q></dir></style></legend>

                <i id='leruA'><tr id='leruA'><dt id='leruA'><q id='leruA'><span id='leruA'><b id='leruA'><form id='leruA'><ins id='leruA'></ins><ul id='leruA'></ul><sub id='leruA'></sub></form><legend id='leruA'></legend><bdo id='leruA'><pre id='leruA'><center id='leruA'></center></pre></bdo></b><th id='leruA'></th></span></q></dt></tr></i><div id='leruA'><tfoot id='leruA'></tfoot><dl id='leruA'><fieldset id='leruA'></fieldset></dl></div>
                  <bdo id='leruA'></bdo><ul id='leruA'></ul>
                • 本文介绍了NuGet 包显示没有依赖项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我尝试从 .NET 4.7.2 类库 (VS2017) 制作 NuGet 包,但生成的 NuGet 包令人惊讶地没有显示依赖项(这是一个错误).

                  I try to make a NuGet package from a .NET 4.7.2 class library (VS2017), but the resulting NuGet package surprisingly shows no dependencies (which is an error).

                  我的设置是这样的:

                  • 我的类库是 .NET Framework 4.7.2
                  • 我的类库使用另一个 NuGet 包(具有 依赖项).
                  • 我的类库在 .csproj 中使用 packageReferences
                  • 我的类库包含一个正确的 .nuspec 文件
                  • 我使用 nuget.exe 包 来创建包
                  • My class library is .NET Framework 4.7.2
                  • My class library uses another NuGet package (that has dependencies).
                  • My class library uses packageReferences in .csproj
                  • My class library contains a proper .nuspec file
                  • I use nuget.exe pack for creating the package

                  nuget.exe pack 命令应该自动 填充所需的依赖项 - 这也曾经是早期的情况(在另一个项目中).但是,当时我在我的类库中使用了 packages.config 而不是 packageReferences.这有什么改变吗?

                  The nuget.exe pack command should automatically fill in the needed dependencies - this also used to be the case earlier (in another project). However, at that time I used packages.config instead of packageReferences with my class library. Does that change anything?

                  发生了什么事?

                  如何强制系统在我的包中再次包含所需的依赖项?

                  注意事项:

                  • 该包是由我们的 TeamCity 构建服务器上的 MSBuild 脚本构建的(没有 VS2017).构建脚本调用 "nuget.exe restore" 和后来的 "nuget.exe pack" 作为其构建逻辑的一部分.

                  • The package is built by a MSBuild script on our TeamCity build server (without VS2017). It's the build script that calls both "nuget.exe restore" and later "nuget.exe pack" as part of its build logic.

                  MSBuild 是 15.7 版

                  MSBuild is version 15.7

                  nuget.exe 是 4.6.2 版

                  nuget.exe is version 4.6.2

                  推荐答案

                  如何强制系统在我的包中再次包含所需的依赖项?

                  How can I force the system to again include the needed dependencies in my package?

                  这是一个关于 nuget pack 在使用 PackageReference 而不是 packages.config 时忽略依赖项的已知问题.

                  要解决此问题,您可以使用以下解决方法,NuGet 团队仍在积极努力改进此方案:

                  To resolve this issue, you can use the following workaround, and NuGet team are still actively working on improving this scenario:

                  打包您的 C# 类库,该类库通过以下方式管理您的依赖项PackageReference 在 csproj 本身中,

                  To package your C# Class Library which manages your dependencies via PackageReference in the csproj itself,

                  请添加参考NuGet.Build.Tasks.Pack (https://www.nuget.org/packages/NuGet.Build.Tasks.打包/) 并运行msbuild/t:pack 从命令行.

                  please add a reference to NuGet.Build.Tasks.Pack ( https://www.nuget.org/packages/NuGet.Build.Tasks.Pack/) and run msbuild /t:pack from the command line.

                  我已经测试了这个解决方法,它工作正常.为确保此解决方法正常工作,我们需要注意以下要点:

                  I have test this workaround, it works fine. To make sure this workaround works fine, we need to pay attention to the following points:

                  • 需要将nuget包NuGet.Build.Tasks.Pack添加到项目中.
                  • 需要添加属性/p:PackageOutputPath="D:TesterFolder" -p:Authors=tester
                  • 使用命令 msbuild.exe/t:pack,例如:msbuild.exe/t:pack "MyTestLibrary.csproj"/p:PackageOutputPath="D:TestFolder" -p:Authors=tester
                  • Need to add the nuget package NuGet.Build.Tasks.Pack to the project.
                  • Need to add properties /p:PackageOutputPath="D:TesterFolder" -p:Authors=tester
                  • Use the command msbuild.exe /t:pack, like: msbuild.exe /t:pack "MyTestLibrary.csproj" /p:PackageOutputPath="D:TestFolder" -p:Authors=tester

                  另外,如果你想使用.nuspec文件来创建nuget包,你应该使用下面的.nuspec文件:

                  Besides, if you want to use .nuspec file to create the nuget package, you should use the following .nuspec file:

                  <?xml version="1.0"?>
                  <package >
                    <metadata>
                      <id>MyTestLibrary</id>
                      <version>1.0.0</version>
                      <authors>Tester</authors>
                      <owners>Tester</owners>
                      <requireLicenseAcceptance>false</requireLicenseAcceptance>
                      <description>Package description</description>
                      <releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
                      <copyright>Copyright 2018</copyright>
                      <tags>Tag1 Tag2</tags>
                      <dependencies>
                        <group targetFramework=".NETFramework4.7.2">
                          <dependency id="Microsoft.Owin" version="4.0.0" exclude="Build,Analyzers" />
                        </group>
                      </dependencies>
                    </metadata>
                  
                      <files>
                          <file src="binDebugMyTestLibrary.dll" target="lib
                  et472MyTestLibrary.dll" />
                      </files>
                  </package>
                  

                  然后我们可以使用 nuget.exe pack 来创建 nuget 包.但是,使用这种方法,我们必须在 .nuspec 文件中手动填写所需的依赖项.

                  Then we could use nuget.exe pack to create the nuget package. But, using this method, we have to manually fill in the needed dependencies in the .nuspec file.

                  希望这会有所帮助.

                  这篇关于NuGet 包显示没有依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何将本地数据库文件添加到 Visual Studio Mac 2017 下一篇:Visual Studio 2017 中源文件的默认编码是什么?

                  相关文章

                • <legend id='xqmHu'><style id='xqmHu'><dir id='xqmHu'><q id='xqmHu'></q></dir></style></legend>

                    <small id='xqmHu'></small><noframes id='xqmHu'>

                    <i id='xqmHu'><tr id='xqmHu'><dt id='xqmHu'><q id='xqmHu'><span id='xqmHu'><b id='xqmHu'><form id='xqmHu'><ins id='xqmHu'></ins><ul id='xqmHu'></ul><sub id='xqmHu'></sub></form><legend id='xqmHu'></legend><bdo id='xqmHu'><pre id='xqmHu'><center id='xqmHu'></center></pre></bdo></b><th id='xqmHu'></th></span></q></dt></tr></i><div id='xqmHu'><tfoot id='xqmHu'></tfoot><dl id='xqmHu'><fieldset id='xqmHu'></fieldset></dl></div>
                  1. <tfoot id='xqmHu'></tfoot>
                      <bdo id='xqmHu'></bdo><ul id='xqmHu'></ul>