c# - NuGet:包含可作为库引用的源代码的包

标签 c# nuget nuget-package

是否有可能创建一个包含可作为库引用的源代码的 NuGet 包? 当我使用 .nuspec 打包时,创建的 .nupkg 包含源代码,但无法引用。我已经尝试按照一些建议在 .nuspec 中添加库节点,但生成的 .nuspec 与标准不匹配,因此无法创建。 使用 .csproj 打包时,.nupkg 仅包含 .dll。可以引用但不能调试,因为它不包含任何源代码。 我怎样才能同时实现这两个目标?包含源代码的可引用库。 预先感谢您的宝贵时间。

最佳答案

这是一个 .nuspec 文件,我用来打包来自多个目录的源代码,这些目录在其他项目中用作库:

<?xml version="1.0"?>
<package >
  <metadata>
    <id>Your.Package</id>
    <version>1.0.14</version>
    <authors>me</authors>
    <owners>me</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Class library.</description>
    <releaseNotes>Initial release.</releaseNotes>
    <copyright>Copyright 2017</copyright>
    <tags>some tags</tags>
  </metadata>
  <files>
    <file src="*.cs" target="content/App_Packages/<YourPackage>.Sources" />
    <file src="Configuration/*.cs" target="content/App_Packages/<YourPackage>.Sources" />
  </files>
</package>

只需更改"file"标签即可引用您要包含的文件。

当您准备好创建 .nupkg 文件时,请 cd 到包含 .nuspec 文件的目录并运行: nuget 包.nuspec

关于c# - NuGet:包含可作为库引用的源代码的包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38514532/

相关文章:

c# - DbContext 的 ObjectContext.ApplyCurrentValues 的等价物是什么

nuget - 如何解决 "Unable to find package"nuget 错误

dll - System.Net.Http NuGet 包 4.3.0 引用在 System.Diagnostics.DiagnosticSource 版本 4.0.0.0 引用上生成 System.IO.FileLoadException

msbuild - 通过 Nuget 使用 .NET Standard 和 VS2017 分发自定义 MSBuild 任务

c# - .NET Core 中的 MethodInfo ReflectedType

c# - 什么是 PromptOptions.Validations

nuget - 如何通过 NuGet 包安装更改现有文件?

compiler-errors - 如何解决 “The type or namespace name ' Didstopia'找不到(您是否缺少using指令或程序集引用?)”

c# - 静态变量是线程安全的吗? C#

.net - NuGet:自动迁移对包的引用