TFS Nuget Packager 构建步骤包括 nupkg 文件中的代码 (*.cs) 文件

TFS Nuget Packager build step included the code(*.cs) files in the nupkg file

在 TFS 中,我添加了一个步骤 "Nuget Packager"。该项目构建良好,但当我解压缩 nupkg 文件时,它包含项目文件(.csproj、.cs、*.config 文件)。我希望只有二进制文件(例如 bin\Release*.dll 文件)。我在构建定义中遗漏了什么?

更新

建议您使用 .csproj 而不是 **\*.nuspec 要打包 Pack 的 csproj 或 nuspec 文件的路径中NuGet 任务。这将在 TFS 中获得与本地相同的结果。

通过 nuget spec 命令自动创建 .nuspec 包清单。 XML 清单文件如下所示:

  <metadata>
    <id>C:\Users\xx\Source\Workspaces\Workspace\TestNuGetPackager\TestNuGetPackager\xx.csproj</id>
    <version>1.0.0</version>
    <authors>xxx</authors>
    <owners>xxx</owners>
    <licenseUrl>http://LICENSE_URL_HERE_OR_DELETE_THIS_LINE</licenseUrl>
    <projectUrl>http://PROJECT_URL_HERE_OR_DELETE_THIS_LINE</projectUrl>
    <iconUrl>http://ICON_URL_HERE_OR_DELETE_THIS_LINE</iconUrl>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Package description</description>
    <releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
    <copyright>Copyright 2017</copyright>
    <tags>Tag1 Tag2</tags>
    <dependencies>
      <dependency id="SampleDependency" version="1.0" />
    </dependencies>
  </metadata>
</package>

您需要手动更改 .nuspec 文件的值,如下所示,包括详细 dll 和硬编码一些信息

<package >
  <metadata>
    <id>TestNuGetPackager</id>
    <version>1.0.0</version>
    <authors>Test</authors>
    <owners>Test</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Package description</description>
    <releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
    <copyright>Copyright 2017</copyright>
    <tags>Tag1 Tag2</tags>
  </metadata>
    <files>
        <file src="bin\Release\TestNuGetPackager.dll" target="lib"/>
    </files>
</package>

在此之后您将获得唯一的二进制文件,否则使用系统自动生成的 .nuspec 文件,您将打包包括项目文件。需要将修改后的 .nuspec 文件检入到 TFS 并再次触发构建。

更多关于如何使用 .nuspec 文件的详细信息请参考本教程:The role and structure of the .nuspec file