【发布时间】:2021-01-13 13:35:18
【问题描述】:
在 Ubuntu 上,我想将一些 C# DLL 文件包装到 NuGet 包中。在 Windows 上可以使用NuGet package explorer or nuget.exe + manually edited *.csproj.nuspec。总之,当手动编辑 *.nuspec 文件时,可以通过 <files> 部分添加 DLL:
<files>
<file src="some\Path\YourDll.dll" target="lib"></file>
</files>
在 Ubuntu 上,我想改用 dotnet pack。但是它似乎无法对*.csproj.nuspec 文件进行操作:
Usage: dotnet pack [options] <PROJECT | SOLUTION>
Arguments:
<PROJECT | SOLUTION> The project or solution file to operate on. If a file is not specified, the command will search the current directory for one.
Options:
-h, --help Show command line help.
-o, --output <OUTPUT_DIR> The output directory to place built packages in.
--no-build Do not build the project before packing. Implies --no-restore.
--include-symbols Include packages with symbols in addition to regular packages in output directory.
--include-source Include PDBs and source files. Source files go into the 'src' folder in the resulting nuget package.
-c, --configuration <CONFIGURATION> The configuration to use for building the package. The default for most projects is 'Debug'.
--version-suffix <VERSION_SUFFIX> Set the value of the $(VersionSuffix) property to use when building the project.
-s, --serviceable Set the serviceable flag in the package. See https://aka.ms/nupkgservicing for more information.
--nologo Do not display the startup banner or the copyright message.
--interactive Allows the command to stop and wait for user input or action (for example to complete authentication).
--no-restore Do not restore the project before building.
-v, --verbosity <LEVEL> Set the MSBuild verbosity level. Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic].
--runtime <RUNTIME_IDENTIFIER> The target runtime to restore packages for.
--no-dependencies Do not restore project-to-project references and only restore the specified project.
--force Force all dependencies to be resolved even if the last restore was successful.
This is equivalent to deleting project.assets.json.
我可以在 Ubuntu 上使用 dotnet CLI 将 C# DLL 包装到 NuGet 包中吗?还是我必须使用nuget CLI (apt-get install nuget) 来代替 Windows 上的方法?
【问题讨论】:
-
*.csproj.nuspec文件是什么?它们不是两个不同的文件吗? -
@PavelAnikhouski 是的,当然这是单独的文件。在
*.csproj.nuspec中,可以定义要包含在nuget 包中的DLL。问题是这是否也可以通过*.csproj实现。然后我可以使用dotnet pack。否则我可能不得不改用nuget。 -
您可以直接在
.cspoj文件中定义属性,如此处所述Create and publish a package (dotnet CLI) -
你的意思是通过
<ItemGroup>?
标签: c# .net ubuntu dll nuget-package