与此问题相关:Is it possible to set project's Output Path property from nuget powershell?
如何将项目的输出路径设置为使用宏?就像在csproj文件中编辑它一样。
(Get-Project).ConfigurationManager.ActiveConfiguration.Properties.Item("OutputPath").Value =
"$(SolutionDir)bin"这解决了
<OutputPath>%24%28SolutionDir%29\bin</OutputPath>但应该是
<OutputPath>$(SolutionDir)\bin</OutputPath>发布于 2015-11-12 15:59:06
我找到了一种通过xml更改csproj的解决方法。
function Set-OutputPathRaw( $projectObj, $outputPath )
{
<#
.SYNOPSIS
Set the output path directly in the csproj file
.PARAMETER projectObj
The project to set
.PARAMETER outputPath
The path to set in the output path. May use dollar-sign macros
#>
$projectObj.Save() # save beforehand
$csproj = [xml](Get-Content $projectObj.FullName)
$nsmgr = New-Object System.Xml.XmlNamespaceManager -ArgumentList $csproj.NameTable
$nsmgr.AddNamespace('a', 'http://schemas.microsoft.com/developer/msbuild/2003')
$outputpathnodes = $csproj.SelectNodes('/a:Project/a:PropertyGroup/a:OutputPath/text()',$nsmgr)
foreach($outputnode in $outputpathnodes)
{
$outputnode.Value = $outputPath
}
$csproj.Save($projectObj.FullName)
}通过以下方式调用:
Set-OutputPathRaw $project "`$(SolutionRoot)\bin\`$(Configuration)"https://stackoverflow.com/questions/33630705
复制相似问题