2017-08-02 87 views
1

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

+0

您可以共享“的NuGet打包”任务的详细设置:

更多有关如何使用.nuspec文件请参见本教程的详细信息? –

回答

1

更新

建议你使用.csproj代替**\*.nuspec路径的csproj或nuspec文件(S)收拾包的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\46"/> 
    </files> 
</package> 

这之后,您将获得唯一的二进制文件,否则使用系统自动生成的.nuspec文件,你将打包包含项目文件。需要检查修改后的.nuspec文件到TFS并再次触发构建。 The role and structure of the .nuspec file

+0

我原来是这样的,但它没有帮助 – alltej

+0

@alltej您可以打包'** \ *。nuspec'文件,而不是'.csproj'文件。随着创建一个.nuspec包清单。清单是一个XML文件,用于描述软件包的内容**,并且它本身包含在软件包中。有关如何使用.nuspec文件的更多详细信息,请参阅本教程:https://docs.microsoft.com/en-us/nuget/create-packages/creating-a-package#the-role-and-structure-of- the-nuspec-file –

+0

是的,我确实使用了nuspec文件。它是在与* .csproj文件相同的目录下使用'nuget spec'创建的。 – alltej