Powershell编辑Xml导致Visual Studio报告不一致的行结束
发布时间:2020-12-16 07:48:36 所属栏目:百科 来源:网络整理
导读:Power shell初学者在这里.. 所以我用PowerShell脚本创建了一个Nuget包. powershell脚本在安装Visual Studio项目时修改了xml架构.问题是…. 如果在xml文件中有多行块注释,如 !--foo bar /bar/foo-- 脚本运行后,Visual Studio弹出一条消息,说我的文件有“不一
Power
shell初学者在这里..
所以我用PowerShell脚本创建了一个Nuget包. powershell脚本在安装Visual Studio项目时修改了xml架构.问题是…. 如果在xml文件中有多行块注释,如 <!--<foo> <bar> </bar> </foo>--> 脚本运行后,Visual Studio弹出一条消息,说我的文件有“不一致的行结束……” 如果没有评论,或者如果有单行注释 <!--foo--> 没有问题.以某种方式,以块注释结尾的行由powershell函数从CRLF更改为其他内容. 这是我的powershell脚本,用于加载和保存xml文件 [xml]$xml = gc $xmlFileLocation -encoding utf8 $xml.Save($xmlFileLocation) 我也尝试过类似的东西 set-content -encoding utf8 $xmlFileLocation $xml.outerXml 但我继续得到这个消息…… 任何sugguests /帮助将非常感激.
通过Out-String管道获取内容:
[xml] $xml = Get-Content 'foo.xml' | Out-String $xml.foo.bar = 'baz' $xml.Save('foo.xml') 我刚测试了这个:没有Out-String,我在Visual Studio中看到了这条消息.使用Out-String,我没有,并且评论是孤立的. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |