简体   繁体   English

如何将 C# DLL 包装到 Ubuntu 上的 NuGet package?

[英]How can I wrap C# DLLs into a NuGet package on Ubuntu?

On Ubuntu I'd like to wrap a few C# DLL files into a NuGet package. On Windows one would use the NuGet package explorer or nuget.exe + manually edited *.csproj.nuspec . On Ubuntu I'd like to wrap a few C# DLL files into a NuGet package. On Windows one would use the NuGet package explorer or nuget.exe + manually edited *.csproj.nuspec . In summary when manually editing the *.nuspec file one may add DLLs via the <files> section:总之,当手动编辑*.nuspec文件时,可以通过<files>部分添加 DLL:

<files>
   <file src="some\Path\YourDll.dll" target="lib"></file>
</files>

On Ubuntu I'd like to use do.net pack instead.在 Ubuntu 上,我想改用do.net pack However it seems like it's not able to operate on a *.csproj.nuspec file:但是它似乎无法对*.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.

Can I wrap C# DLLs into a NuGet package on Ubuntu using the do.net CLI?我可以使用do.net CLI 将 C# DLL 包装成 NuGet package on Ubuntu 吗? Or do I have to use the nuget CLI ( apt-get install nuget ) instead with the approach like on Windows?或者我是否必须使用nuget CLI ( apt-get install nuget ) 而不是像 Windows 那样的方法?

I would add this into the.csproj file:我会将其添加到 .csproj 文件中:

<ItemGroup>
    <Content Include="some.dll" PackageCopyToOutput="true">
        <pack>true</pack>
        <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
</ItemGroup>

It's not pretty but it works.它不漂亮,但它有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM