我创建了一个基于 .Net Standard 2.0 的类库,并使用 Cake 构建项目/解决方案,但我找不到如何为该库构建 NuGet 包。 NuGetPack 不起作用。
最佳答案
你确实有两个选择。 NuGetPack
将继续工作,我在我维护的几个 Cake Addins 上使用了这种方法。您能否详细解释一下您所遇到的问题?
另一个选项是使用 DotNetCorePack
别名。您可以在此文件中看到此操作(它是 Cake.Recipe 脚本集的一部分):
https://github.com/cake-contrib/Cake.Recipe/blob/develop/Cake.Recipe/Content/nuget.cake
这里也记录了它:
https://cakebuild.net/api/Cake.Common.Tools.DotNetCore/DotNetCoreAliases/0F7A518E
var projects = GetFiles(BuildParameters.SourceDirectoryPath + "/**/*.csproj")
- GetFiles(BuildParameters.SourceDirectoryPath + "/**/*.Tests.csproj");
var settings = new DotNetCorePackSettings {
NoBuild = true,
Configuration = BuildParameters.Configuration,
OutputDirectory = BuildParameters.Paths.Directories.NuGetPackages,
ArgumentCustomization = (args) => {
if (BuildParameters.ShouldBuildNugetSourcePackage)
{
args.Append("--include-source");
}
return args
.Append("/p:Version={0}", BuildParameters.Version.SemVersion)
.Append("/p:AssemblyVersion={0}", BuildParameters.Version.Version)
.Append("/p:FileVersion={0}", BuildParameters.Version.Version)
.Append("/p:AssemblyInformationalVersion={0}", BuildParameters.Version.InformationalVersion);
}
};
foreach (var project in projects)
{
DotNetCorePack(project.ToString(), settings);
}
关于msbuild - 使用 Cake 为 .Net Standard 2.0 lib 构建 NuGet 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47345500/