排除资产在本地工作但不在构建服务器上

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

我有一个使用 nuget 包(winscp)的项目,通常会将winscp.exe复制到bin文件夹中。我必须从另一个位置运行该 exe,因此该副本不是我要查找的内容(只是想获取 WinSCPnet.dll),因此我使用 ExcludeAssets 排除它。它可以在本地运行,但由于某种原因不能在我的构建服务器上运行。

详细信息:我的项目中有一个包参考:

  <PackageReference Include="WinSCP" Version="5.15.0">
      <!-- this prevents the exe from being copied to the bin folder (locally at least) -->
      <ExcludeAssets>build;</ExcludeAssets>
    </PackageReference>

在我的开发计算机上,无论使用 msbuild 还是 vs 2022,这都正确排除了 exe。但是当在构建服务器上构建时包含exe。我发现我的构建命令与构建服务器上执行的命令之间的唯一区别是一些动态属性和日志记录。

"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe" 
    "C:\BuildAgent\Agent01\_work\1301\s\MyApp\MyApp.vbproj" 
    /nologo /nr:false 
    /dl:CentralLogger,
   "C:\BuildAgent\Agent01\_work\_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.179.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll"
;"RootDetailId=|SolutionDir=C:\BuildAgent\Agent01\_work\1301\s\MyApp"*ForwardingLogger,
    "C:\BuildAgent\Agent01\_work\_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.179.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" 
    /p:SatelliteResourceLanguages=en-US 
    /p:OutDir=C:\BuildAgent\Agent01\_work\1301\a/MyApp
    /p:platform="AnyCPU" 
    /p:configuration="Release" 
    /p:_MSDeployUserAgent="TFS_a10cfcba-c039-4792-814d-e9ffd4de1ed7_build_314_0"

我在 ms build bin 文件夹中本地使用的 MSbuild 命令:

   .\MSBuild.exe "C:\Users\jrmoreno\source\repos\MyApp\MyApp\MyApp.vbproj" 
    /nologo 
    /nr:false 
    /p:SatelliteResourceLanguages=en-US 
    /p:OutDir=c:/users/jrmoreno/source/MyApp
    /p:platform="AnyCPU" 
    /p:configuration="Release"
azure-devops msbuild
2个回答
1
投票

NuGet 支持

ExcludeAssets="build"
存在一个未解决的错误。请参阅 NuGet/Home#9672

build
目标应该正在运行
restore
,我认为您的本地构建证明它确实如此。在管道中,让 MSBuild 通过禁用或删除
restore
步骤来执行
NuGet Restore
。您还可以添加一个步骤来显式运行
msbuild /t:restore


0
投票

我通过将“排除资产”反转为“包含资产”来解决这个问题。基本上,您列出了要包含的所有类型:编译等。

© www.soinside.com 2019 - 2024. All rights reserved.