dotnet / project-system

The .NET Project System for Visual Studio
MIT License
968 stars 387 forks source link

[Bug]: NuGet package update reformats multi-line "Exec Command" string in project files #8076

Open nkolev92 opened 2 years ago

nkolev92 commented 2 years ago

@timmkrause commented on Mon, 04 Apr 2022 10:33:33 GMT

NuGet Product Used

Visual Studio Package Management UI

Product Version

Visual Studio 2022 (17.1.3)

Worked before?

No response

Impact

It's more difficult to complete my work

Repro Steps & Context

    <Target Name="NSwag" AfterTargets="Build">
        <Exec Command="
            $(NSwagExe_Net60) openapi2csclient ^
                /input:Infrastructure/Clients/Something/something.json ^
                    /output:Infrastructure/Clients/Something/SomethingApiClient.generated.cs ^
                /classname:SomethingApiClient ^
                /namespace:Something ^
                /GeneratePrepareRequestAndProcessResponseAsAsyncMethods:True ^
                /JsonLibrary:SystemTextJson ^
        " />
    </Target>
<Target Name="NSwag" AfterTargets="Build">
    <Exec Command="&#xD;&#xA;           $(NSwagExe_Net60) openapi2csclient ^&#xD;&#xA;              /input:Infrastructure/Clients/Something/something.json ^&#xD;&#xA;              /output:Infrastructure/Clients/Something/SomethingApiClient.generated.cs ^&#xD;&#xA;                /classname:SomethingApiClient ^&#xD;&#xA;               /namespace:Something ^&#xD;&#xA;                /GeneratePrepareRequestAndProcessResponseAsAsyncMethods:True ^&#xD;&#xA;                /JsonLibrary:SystemTextJson ^&#xD;&#xA;     " />
</Target>

Verbose Logs

No response

nkolev92 commented 2 years ago

@timmkrause commented on Mon, 11 Apr 2022 14:34:42 GMT @dominoFire You can find a repro here:

https://github.com/timmkrause/NuGetReformattingIssueRepro

Either install a new package via the UI or update the existing System.Text.Json to reproduce the reformatting of

  <Target Name="NSwag" AfterTargets="Build">
    <Exec Command="
      echo foo ^
      echo bar ^
    " />
  </Target>

to

  <Target Name="NSwag" AfterTargets="Build">
    <Exec Command="&#xD;&#xA;      echo foo ^&#xD;&#xA;      echo bar ^&#xD;&#xA;    " />
  </Target>
nkolev92 commented 2 years ago

@nkolev92 commented on Wed, 13 Apr 2022 21:21:14 GMT NuGet calls Microsoft.VisualStudio.ProjectSystem.References.AddAsync, which is owned by dotnet/project-system.

I'll copy over the issue there.

nkolev92 commented 2 years ago

https://github.com/NuGet/NuGet.Client/blob/2f609f59dee750a4670838701b0de83792ff7402/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Projects/CpsPackageReferenceProject.cs#L289 and https://github.com/NuGet/NuGet.Client/blob/2f609f59dee750a4670838701b0de83792ff7402/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Projects/CpsPackageReferenceProject.cs#L319 are where NuGet makes the calls for reference for the exact APIs