Skip to content

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

Closed

Description

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

Activity

  1. added
    bug
    triage needed
    on Jun 30, 2021
  2. changed the title [-]PowerShell Set-GitHubContent messes up the encoding of the csproj file[/-] [+]PowerShell Set-GitHubContent breaking the encoding of the csproj file[/+] on Jun 30, 2021
  3. added
    api-contents
    and removed
    triage needed
    on Jun 30, 2021
  4. HowardWolosky commented on Jun 30, 2021

    @HowardWolosky
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-contentsbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions