【发布时间】:2012-05-04 02:49:24
【问题描述】:
我有以下 ps1 文件。该文件存在三个问题。
第一季度。如何在 XML 中使用单引号和双引号?我用谷歌搜索,发现我需要多加一个单引号。我试过但没有用。
第二季度。当我将新的 PropertyGroup 作为子项附加到 Project 节点时,出现“错误类型”错误。我该如何解决。
第三季度。我可以将多个 PropertyGroup 附加到项目节点吗?
$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);
}
提前致谢!
【问题讨论】:
标签: powershell csproj