[英]MSBuild not publishing Web.config to the root of the publish folder
我從 PowerShell 運行以下 MSBuild 命令來發布解決方案文件:
$Configuration = "Release"
$slnFullPath = "...\Solution.sln";
$PublishPath = "$RepoRoot\output-path\$Configuration"
$LogVerbosity = "q"
$msbuildOptions = @(
$slnFullPath
, "/t:Build"
, "/p:Configuration=$Configuration"
, "/p:DeployOnBuild=true"
, "/p:publishUrl=$PublishPath"
, "-detailedSummary"
, "-m"
, "/p:BuildInParallel=true"
, "-nologo"
, "-binaryLogger:LogFile=$logsPath\$Configuration.binlog"
, "-verbosity:$LogVerbosity"
, "/consoleLoggerParameters:ShowTimestamp; ErrorsOnly; ShowEventId; PerformanceSummary; Summary;"
);
Write-Host "Command - & msbuild $msbuildOptions" -ForegroundColor DarkCyan
& msbuild $msbuildOptions
當我檢查 output 文件夾時,根目錄中不存在 web.config,但我可以在“bin”文件夾下看到它。 Web.config 當前在 csproj 文件中標記為內容。
<Content Include="Web.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
我注意到,如果我重命名該文件(例如,將其重命名為Web2.config ),則會出現該文件。 這是正常的 MSBuild 行為嗎? 如何強制將 Web.config 發布到 output 路徑的根目錄?
嘗試將$msbuildOptions
更改為@msbuildOptions
。 這稱為飛濺。
“Splatting 是一種將參數值集合作為一個單元傳遞給命令的方法。”
& msbuild @msbuildOptions
有時您需要為項目的每個配置配置一個版本的.config
。 這取決於您的配置,如果部署Release
配置,這將是Web.Release.config
。 但我認為這個版本不是真正的配置,而是一個 xslt 文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.