[英]How am I supposed to be building NuGet packages?
I have a few functions I want to make available to many projects I'm working on. 我有一些功能想提供给我正在从事的许多项目。 So naturally I thought I should make a NuGet package to contain the shared code. 所以自然而然地,我想我应该制作一个NuGet包来包含共享代码。 so I: 所以我:
ADUserCacheUsage.csproj
, and in a command window did nuget spec
. 使用ADUserCacheUsage.csproj
进入目录,并在命令窗口中执行nuget spec
。 This generated a .nuspec
file. 这将生成一个.nuspec
文件。 nuget pack ADUserCacheUsage.csproj -Build -Symbols -Properties Configuration=Release
(after all, if someone externally is using the package, they only need the release build, right?) nuget pack ADUserCacheUsage.csproj -Build -Symbols -Properties Configuration=Release
(毕竟,如果有人在外部使用该软件包,他们只需要发布版本,对吗?) nuget add ADUserCacheUsage.1.0.0.nupkg -source "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages"
So great, my NuGet package shows up when I select the machine source in the package manager. 太好了,当我在程序包管理器中选择机器源时,会显示我的NuGet程序包。 So I can use it in my projects. 所以我可以在项目中使用它。
I'm making a sample web page to use it. 我正在制作一个示例网页来使用它。 All the sample does is call one function and output the result on a web page. 该示例所做的只是调用一个函数并在网页上输出结果。
The problem is, whenever I try and run this sample project in debug mode, I get the warning message 问题是,每当我尝试在调试模式下运行此示例项目时,我都会收到警告消息
You are debugging a Release build of ADUserCacheUsage.dll. 您正在调试ADUserCacheUsage.dll的发布版本。
So presumably I should be including a debug version of my class library in my package, in addition to the release version, right? 因此,大概应该在发行版之外,在包中包括类库的调试版本,对吗? I wouldn't want the final release of the sample project to bother with the debugging information, potentially being slow and bloated (admittedly not much of an issue on a project that's just a sample, but I'm thinking for best practices and in the future where I might have a larger, more complex package). 我不希望示例项目的最终发行版会打扰调试信息,因为调试信息可能会很慢而且很blo肿(诚然,在一个仅作为示例的项目中,这个问题并不多,但是我正在考虑最佳实践,并且在将来我可能会有更大,更复杂的软件包)。
But I want to be able to run in debug without this error. 但我希望能够在调试中运行而不会出现此错误。 Whenever I make a web project, it includes many other projects, and it never gives me this error with regard to, for example, NewtonSoft.json
. 每当我创建一个Web项目时,它都会包含许多其他项目,并且从不会给我有关NewtonSoft.json
。 So what should I be doing in order to do this the right way? 那么,我应该怎么做才能正确地做到这一点? Does every package on nuget.org just include the debug version? nuget.org上的每个软件包是否都包含调试版本?
NuGet packages don't contain debug information. NuGet软件包不包含调试信息。
Instead, there are separate NuGet symbol packages (ending with .symbols.nupkg
) that contain debug symbols ( .pdb
files) and the source code files. 而是有单独的NuGet符号包(以.symbols.nupkg
结尾) ,其中包含调试符号( .pdb
文件)和源代码文件。 Symbol packages can be created using either the nuget pack -Symbols
or dotnet pack --include-symbols
command tools. 可以使用nuget pack -Symbols
或dotnet pack --include-symbols
nuget pack -Symbols
dotnet pack --include-symbols
命令工具来创建符号包。
After the symbols packages are created and hosted (either on a symbol server or on the local file system), you can configure Visual Studio to use them to step through the code, even though the code in the NuGet package was built using Release
mode. 创建并托管符号包之后(在符号服务器上或在本地文件系统上),即使NuGet包中的代码是使用Release
模式构建的,也可以将Visual Studio配置为使用它们来单步执行代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.