Xml NuGet包的差异取决于构建方法
我有一个.NET核心项目,我想将其打包为NuGet包,以便在其他Visual Studio项目/解决方案中使用。在.NET核心项目中,有一个很好的特性,您可以在项目属性中进行选择,以便在构建时生成NuGet包,我已经尝试过了。结果是一个包,我们称之为Xml NuGet包的差异取决于构建方法,xml,visual-studio,nuget,nuspec,Xml,Visual Studio,Nuget,Nuspec,我有一个.NET核心项目,我想将其打包为NuGet包,以便在其他Visual Studio项目/解决方案中使用。在.NET核心项目中,有一个很好的特性,您可以在项目属性中进行选择,以便在构建时生成NuGet包,我已经尝试过了。结果是一个包,我们称之为My.Company.package,它有一个生成的nuspec文件,如下所示: <?xml version="1.0" encoding="utf-8"?> <package xmlns="http://schemas.micro
My.Company.package
,它有一个生成的nuspec文件,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>My.Company.Package</id>
<version>10.1.2</version>
<authors>My.Company.Package</authors>
<owners>My.Company.Package</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Package Description</description>
<dependencies>
<group targetFramework=".NETCoreApp3.1">
<dependency id="Microsoft.Win32.Registry" version="4.7.0" exclude="Build,Analyzers" />
</group>
</dependencies>
</metadata>
<files>
<file src="C:\dev\MyProduct\bin\Debug\netcoreapp3.1\My.Company.dll" target="lib\netcoreapp3.1\My.Company.dll" />
</files>
</package>
安装后,包似乎工作正常,我可以访问包中应该包含的名称空间和类
由于我不想进入这里的原因,我必须自己打包,没有这个选项。我在Visual Studio中设置了一个生成后事件,该事件运行nuget pack mycompany.nuspec
,mycompany.nuspec如下所示(我尝试模拟生成的事件):
安装后,我无法访问预期的类或名称空间,它似乎没有包含所需的所有内容
第一个选项如何安装这么多在nuspec文件中从未列为依赖项的软件包,我如何模仿它?我不知道到底是什么做的,但在清理和重建我打包的解决方案并重新启动Visual Studio之后,它成功了。我建议您标记您的答案,以便帮助其他社区成员处理类似问题。谢谢:)
Installing:
Microsoft.NETCore.Platforms.3.1.0
Microsoft.Win32.Registry.4.7.0
My.Company.Package.10.1.2
System.Security.AccessControl.4.7.0
System.Security.Principal.Windows.4.7.0
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>My.Company.Other.Package</id>
<version>10.1.214</version>
<authors>My Company</authors>
<description>
The real description.
</description>
<copyright>© My company</copyright>
<tags>My company</tags>
<dependencies>
<group targetFramework=".NETCoreApp3.1">
<dependency id="Microsoft.Win32.Registry" version="4.7.0" exclude="Build,Analyzers" />
</group>
</dependencies>
</metadata>
<files>
<file src="C:\dev\MyProduct\bin\Debug\netcoreapp3.1\My.Company.dll" target="lib\netcoreapp3.1\My.Company.dll" />
</files>
</package>
Installing:
My.Company.Package.10.1.2