Jef*_*yXu 8 xml powershell visual-studio-2010 nuget
Powershell初学者在这里..
所以我用PowerShell脚本创建了一个Nuget包.powershell脚本在安装Visual Studio项目时会修改其中的xml架构.问题是....
如果在xml文件中有多行块注释,如
<!--<foo>
<bar>
</bar>
</foo>-->
Run Code Online (Sandbox Code Playgroud)
脚本运行后,Visual Studio弹出一条消息,说我的文件有"不一致的行结束......"
如果没有评论,或者如果有单行注释
<!--foo-->
Run Code Online (Sandbox Code Playgroud)
没有问题.以某种方式,以块注释结尾的行由powershell函数从CRLF更改为其他内容.
这是我的powershell脚本,用于加载和保存xml文件
[xml]$xml = gc $xmlFileLocation -encoding utf8
$xml.Save($xmlFileLocation)
Run Code Online (Sandbox Code Playgroud)
我也尝试过类似的东西
set-content -encoding utf8 $xmlFileLocation $xml.outerXml
Run Code Online (Sandbox Code Playgroud)
但我继续得到这个消息......
任何sugguests /帮助将非常感激.
管道Get-Content穿过Out-String:
[xml] $xml = Get-Content 'foo.xml' | Out-String
$xml.foo.bar = 'baz'
$xml.Save('foo.xml')
Run Code Online (Sandbox Code Playgroud)
我刚测试了这个:没有Out-String,我在Visual Studio中看到了这条消息.有Out-String,我没有,评论是孤立的.
| 归档时间: |
|
| 查看次数: |
767 次 |
| 最近记录: |