Nuget Pack 命令不遵守 Azure Pipeline 上的 -Exclude 标志

问题描述 投票:0回答:1

我正在尝试通过 Azure Pipleine 捆绑并发布一个私有 nuget 包,但捆绑包包含一些导致问题的已编译 EF 文件。

下面的输出是 Azure Pipeline 构建的日志。该项目有一个 EF edmx 文件及其相应的

.vb
.Context.vb
文件。

- ROOT
  - DataLayer
    - EntityFramework
      - Common_Model.context.vb
      - Common_Model.edmx
      - Common_Model.vb

将现有的 nuget 包(来自下面的构建过程)添加到项目中时,它将添加数据层、ef 和一些 *.tt 文件的文件夹:

- ROOT
  - DataLayer
    - EntityFramework
      - Common_Model.context.tt
      - Common_Model.tt

这会导致引用 nuget 包的任何项目出现构建问题。因此,我尝试使用该命令排除

nuget pack
命令中的这些文件,但它不起作用...

> nuget.exe pack Company_PR_WS\Company_PR.vbproj -version 1.0.26 -Verbosity detailed -Exclude *.tt -OutputDirectory D:\a\8\a -Properties Configuration=release -NonInteractive
Starting: NuGet custom pack
==============================================================================
Task         : NuGet
Description  : Restore, pack, or push NuGet packages, or run a NuGet command. Supports NuGet.org and authenticated feeds like Azure Artifacts and MyGet. Uses NuGet.exe and works with .NET Framework apps. For .NET Core and .NET Standard apps, use the .NET Core task.
Version      : 2.236.1
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/package/nuget
==============================================================================
C:\Windows\system32\chcp.com 65001
Active code page: 65001
Detected NuGet version 6.9.1.3 / 6.9.1+guid.guid2
C:\hostedtoolcache\windows\NuGet\6.9.1\x64\nuget.exe pack Company_PR_WS\Company_PR.vbproj -version 1.0.26 -Verbosity detailed -Exclude *.tt -OutputDirectory D:\a\8\a -Properties Configuration=release -NonInteractive
NuGet Version: 6.9.1.3
Attempting to build package from 'Company_PR.vbproj'.
MSBuild auto-detection: using msbuild version '17.9.5.7608' from 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\bin'. Use option -MSBuildVersion to force nuget to use a specific version of MSBuild.
Packing files from 'D:\a\8\s\Company_PR_WS\bin\Debug'.
Add file 'D:\a\8\s\Company_PR_WS\bin\Debug\Company_WS.dll' to package as 'lib\net481\Company_WS.dll'
WARNING: NU5116: 'DataLayer\EntityFramework\Common_Model.Context.cs' was included in the project but doesn't exist. Skipping...
Add file 'D:\a\8\s\Company_PR_WS\DataLayer\EntityFramework\Common_Model.Context.tt' to package as 'content\DataLayer\EntityFramework\Common_Model.Context.tt'
WARNING: NU5116: 'DataLayer\EntityFramework\Common_Model.cs' was included in the project but doesn't exist. Skipping...
Add file 'D:\a\8\s\Company_PR_WS\DataLayer\EntityFramework\Common_Model.tt' to package as 'content\DataLayer\EntityFramework\Common_Model.tt'
Found packages.config. Using packages listed as dependencies
WARNING: NU5115: Description was not specified. Using 'Description'.

Id: Company_WS
Version: 1.0.26
Authors: Company Inc.
Description: Description
Dependencies: EntityFramework [6.2.0, ), Microsoft.Bcl.AsyncInterfaces [5.0.0, ), Newtonsoft.Json [13.0.1, ), System.Numerics.Vectors [4.5.0, ), System.Runtime.CompilerServices.Unsafe [5.0.0, ), System.Text.Encodings.Web [5.0.1, ), System.ValueTuple [4.5.0, )

Added file '[Content_Types].xml'.
Added file '_rels/.rels'.
Added file 'Company_WS.nuspec'.
Added file 'content/DataLayer/EntityFramework/Common_Model.Context.tt'.
Added file 'content/DataLayer/EntityFramework/Common_Model.tt'.
Added file 'lib/net481/Company_WS.dll'.
Added file 'package/services/metadata/core-properties/11617f753829432db4d2a240a398a665.psmdcp'.

The package Company_WS.1.0.26 is missing a readme. Go to https://aka.ms/nuget/authoring-best-practices/readme to learn why package readmes are important.
Successfully created package 'D:\a\8\a\Company_WS.1.0.26.nupkg'.

.net entity-framework azure-pipelines nuget
1个回答
0
投票

根据您的描述,您需要排除Nuget包中的*.tt文件。

为了满足您的要求,您需要更改 -exclude 参数的通配符模式格式。

您可以将排除参数从

-Exclude *.tt
更改为
-Exclude **\*.tt

例如:

steps:
- task: NuGetCommand@2
  displayName: 'NuGet custom'
  inputs:
    command: custom
    includeReferencedProjects: true
    arguments: 'pack Company_PR_WS\Company_PR.vbproj -version 1.0.26 -Verbosity detailed -Exclude **\*.tt -OutputDirectory $(Build.ArtifactStagingDirectory) -Properties Configuration=release -NonInteractive'
© www.soinside.com 2019 - 2024. All rights reserved.