Azure devops 通过NuGet';包装';Azure DevOps构建管道中的参数

Azure devops 通过NuGet';包装';Azure DevOps构建管道中的参数,azure-devops,nuget,nuget-package,azure-pipelines,Azure Devops,Nuget,Nuget Package,Azure Pipelines,在我的Azure DevOps构建管道中,我添加了一个pack命令类型的NuGet任务(版本2.*) 我试图传递-Exclude***.tt参数,以便在从其他项目引用时排除这些文件。但是,在生成的NuGet包中,这些.tt文件显示在Content文件夹中 写入主机日志的命令为: nuget.exe pack PROJECTNAME.csproj -NonInteractive -OutputDirectory SOME_OUTPUTPATH -Properties "Configuration=

在我的Azure DevOps构建管道中,我添加了一个pack命令类型的NuGet任务(版本2.*)

我试图传递
-Exclude***.tt
参数,以便在从其他项目引用时排除这些文件。但是,在生成的NuGet包中,这些.tt文件显示在Content文件夹中

写入主机日志的命令为:

nuget.exe pack PROJECTNAME.csproj -NonInteractive -OutputDirectory SOME_OUTPUTPATH -Properties "Configuration=release;\"-Exclude ***.tt\"" -Verbosity Detailed
如您所见,exclude不是属性的一部分,但应该作为一个单独的
-exclude
参数

你知道我该如何做到这一点吗?非常感谢

添加了屏幕截图和YAML:

在Azure DevOps构建管道中传递NuGet“Pack”参数

不能以这种方式使用参数
-Exclude
。由于此参数用于
.nuspec
而不是
.csproj
-Exclude
不是项目文件中的属性,因此我们无法将其用于
.csproj

检查nuget文档时,可以看到以下示例:

nuget pack Package.nuspec -exclude "*.exe" -exclude "*.bat"
如果要使用项目文件
.csproj
排除
.tt
文件,则必须转到项目文件以排除此类文件,如:

  <ItemGroup>
    <None Update="**.tt">
      <Pack>False</Pack>
      <Generator>TextTemplatingFileGenerator</Generator>
      <LastGenOutput>Test.txt</LastGenOutput>
    </None>
    ...
  </ItemGroup>
如果我使用参数
-排除“***.cs”
打包此.nuspec文件:

然后我们可以知道,
.cs
被排除在包中


希望这有帮助

当您将
-Exclude
nuget pack.csproj
一起使用时,您需要给出被排除文件的完整路径。但是这里还有另一个问题,Azure DevOps将
-Exclude
附加到
-Properties
中,忽略exlucing,因此我们需要以另一种方式添加
-Exclude
,如何?在NuGet
custom
命令中:

- task: NuGetCommand@2
  inputs:
    command: custom
    arguments: 'pack "$(Build.SourcesDirectory)\Path\To\.csproj" -Exclude "$(Build.SourcesDirectory)\Path\to\*.tt"'
这里是常规
-Exclude
中的日志。在您尝试时,您可以看到nuget pack my
.exe
文件:

在我执行自定义命令后,这里有一个日志,没有
.exe

我的任务是:

- task: NuGetCommand@2
  inputs:
    command: custom
    arguments: 'pack "$(Build.SourcesDirectory)\TestVars\TestVars\TestVars.csproj" -Exclude "$(Build.SourcesDirectory)\TestVars\TestVars\bin\Debug\*.exe"'

在Visual Studio 2015中为我解决了这个问题:

<ItemGroup>
    <None Include="**.tt">
        <Pack>False</Pack>
        <Generator>TextTemplatingFileGenerator</Generator>
        <LastGenOutput>Test.txt</LastGenOutput>
    </None>
    ...
</ItemGroup>

假的
文本模板文件生成器
Test.txt
...

你能分享你的nuget任务吗?(yaml或截图)编辑了原文,非常感谢!我转到我的C#项目,将Context.tt文件(与.edmx相关)的构建操作更改为无。这样的话,所有那些文件在打包后没有包括在内。谢谢!这是一个很好的方法。打包时将考虑
自定义
字段。
- task: NuGetCommand@2
  inputs:
    command: custom
    arguments: 'pack "$(Build.SourcesDirectory)\TestVars\TestVars\TestVars.csproj" -Exclude "$(Build.SourcesDirectory)\TestVars\TestVars\bin\Debug\*.exe"'
<ItemGroup>
    <None Include="**.tt">
        <Pack>False</Pack>
        <Generator>TextTemplatingFileGenerator</Generator>
        <LastGenOutput>Test.txt</LastGenOutput>
    </None>
    ...
</ItemGroup>