简体   繁体   English

tfs build - nuget 仅打包带有 nuspec 的项目

[英]tfs build - nuget package only projects with nuspec

I have a build definition in TFS 2015我在 TFS 2015 中有一个构建定义

在此处输入图片说明

This build definition is triggered by commits to the master and should build the project, run all the tests and publish Nuget package of projects that contain .nuspec files.此构建定义由对主节点的提交触发,应构建项目、运行所有测试并发布包含.nu​​spec 文件的项目的 Nuget 包。

My issue is that i want to pack only projects that contain .nuspec files and not just any project.我的问题是,我想包包含.nu​​spec文件,不是任何项目的项目。

I know that i can specify "**\\*.nuspec" in the path/pattern, but then i would have to explicitly specify id,title,version,desc,etc... for every nuspec and i want it to be taken from the assembly info.我知道我可以在路径/模式中指定“**\\*.nuspec”,但是我必须为每个 nuspec 明确指定 id、title、version、desc 等,我希望它被采用从装配信息。

Is there a way to obtain it?有办法获得吗?

Arik.阿里克。

The .nuspec will not taken the assembly information when generated. .nu​​spec 在生成时不会获取程序集信息。 We need to modify the id, title, version, etc... manually.我们需要手动修改 id、title、version 等。

So we just need to pack the .csproj file directly, which will take the assembly information for the generated package.所以我们只需要直接打包 .csproj 文件,它会带上生成包的汇编信息。

You can create a command line task to do it manually :您可以创建一个命令行任务来手动执行此操作:

for /f "delims=" %%a in ('dir /s/b *.nuspec') do nuget pack %%~dpa%%~na.csproj -IncludeReferencedProjects -Properties Configuration=Release

You can also use a minimalist nuspec file (same for each projects that are supposed nugets packages) to take advantage of metadatas from AssemblyInfo :您还可以使用极简的 nuspec 文件(对于假设为 nugets 包的每个项目都相同)来利用来自 AssemblyInfo 的元数据:

<?xml version="1.0"?>
<package >
  <metadata>
    <id>$id$</id>
    <version>$version$</version>
    <title>$title$</title>
    <authors>Puresharp</authors>
    <owners>Puresharp</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>$id$.$version$</description>
    <releaseNotes></releaseNotes>
    <copyright>$copyright$</copyright>
    <tags>Puresharp</tags>
  </metadata>
</package>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM