我有以下ps1文件。这个文件存在三个问题。
问题1:如何在XML中使用单引号和双引号?我搜索了谷歌并发现需要添加一个额外的单引号。我尝试过了但没有成功。
问题2:当我将新的PropertyGroup作为子节点附加到Project节点时,我得到了“错误类型”的错误。我该如何修复它。
问题3:我可以将多个PropertyGroup附加到Project节点吗?
$dir = "C:\Work\scripttest\output\"
$ns = @{ defaultNamespace = "http://schemas.microsoft.com/developer/msbuild/2003" }
$configs = [xml]"<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Dev-1|AnyCPU'">
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
";
Get-ChildItem $dir *.csproj -recurse |
% {
$content = [xml](gc $_.FullName);
$project = $content.Project;
$project
$project.AppendChild($configs);
# $content.Save($_.FullName);
}
感谢您预先的支持!
<PropertyGroup xmlns="">
这是无效的;我该如何让 'xmlns' 部分消失? - bc3tech