Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8866439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:47:04+00:00 2026-06-14T16:47:04+00:00

Powershell beginner here.. So I’ve created a Nuget package with a powershell script. The

  • 0

Powershell beginner here..

So I’ve created a Nuget package with a powershell script. The powershell script modifies a xml schema inside my Visual Studio project when it gets installed. Problem being….

If there’s a multi-line block comment inside the xml file like

<!--<foo>
   <bar>
   </bar>
</foo>-->

After the script is run Visual Studio pops up a message and says my file has “inconsistent line ending……”

If there is no comment, or if there is a single line comment like

<!--foo-->

There is no problem. Somehow the line ending in the block comment is changed from CRLF to something else by the powershell functions.

This is my powershell script for loading and saving the xml file

 [xml]$xml = gc $xmlFileLocation -encoding utf8

 $xml.Save($xmlFileLocation)

I’ve also tried something along the lines of

 set-content -encoding utf8 $xmlFileLocation $xml.outerXml

But I keep on getting this message…

Any sugguests/help would be much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T16:47:05+00:00Added an answer on June 14, 2026 at 4:47 pm

    Pipe Get-Content through Out-String:

    [xml] $xml = Get-Content 'foo.xml' | Out-String
    $xml.foo.bar = 'baz'
    $xml.Save('foo.xml')
    

    I just tested this: without Out-String, I see the message in Visual Studio. With Out-String, I don’t, and comments are left alone.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

PowerShell/xml beginner here.... I'm trying to append to or remove empty xml nodes using
I have made a powershell script to find my external IP address. Here is
As a beginner: How can I place a path to folder in Powershell script?
I almost have this Powershell script completed but I am stuck at the last
I'm a beginner in powershell and know C# moderately well. Recently I was writing
My powershell code actually reads data from an XML and stores the specific data
My powershell script takes the following parameter: Param($BackedUpFilePath) The value that is getting passed
PowerShell can call commandline batch files. PowerShell script output can be recorded with the
In PowerShell you can use [xml] to mean [System.Xml.XmlDocument]. Do you know where I
I have a simple question, but I am also a beginner in PowerShell. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.