microsoft / PowerShellForGitHub

Microsoft PowerShell wrapper for GitHub API
Other
588 stars 185 forks source link

PowerShell Set-GitHubContent breaking the encoding of the csproj file #331

Closed distributedtestplatform closed 3 years ago

distributedtestplatform commented 3 years ago

Issue Details

I am using PS module PowerShellForGitHub to perform some work in my github repositories. One of actions is to make changes to the net standard project file. For that the function Set-GitHubContent is used. After I push up the changes the project file becomes unreadable by VisualStudio with the error

error : The project file could not be loaded. Name cannot begin with the '.' character, hexadecimal value 0x00. Line 1, position 2.

Clearly the encoding issue as the file is opened fine by notepad and looks good. I cant figure out how the issue is happening. I tried a very simple code and even that code messes up the project file.

Steps to reproduce the issue

    $test=@'
    <Project Sdk="Microsoft.NET.Sdk">
      <PropertyGroup>
       <TargetFramework>netstandard2.0</TargetFramework>
       <Configurations>Debug;Release;AllInOne</Configurations>
     </PropertyGroup>
   </Project>
    '@
    Set-GitHubContent -OwnerName 'aa' -RepositoryName "RepName" -Path "ProjectFile.csproj" -CommitMessage "any"  -Content  "$test" -BranchName "main"

Verbose logs showing the problem

Suggested solution to the issue

Requested Assignment

Operating System

PowerShell Version

Module Version

HowardWolosky commented 3 years ago

Thanks for the report. This was already fixed with #328 back in May. Unfortunately, I haven't been able to release an updated version of the module to PowerShellGallery due to some internal issues that I'm having with getting the module signed due to some changes in the procedure within Microsoft (see here). For the time being, you'll find the problem resolved if you use the module sync'd in the state from this repo as opposed to from PowerShellGallery.