Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Microsoft.Build.Evaluation.Project.Save() clears empty lines from a csproj #5697

Closed
mishra14 opened this issue Aug 1, 2017 · 6 comments
Closed

Comments

@mishra14
Copy link
Contributor

mishra14 commented Aug 1, 2017

From @mishra14 on August 1, 2017 23:0

Original issue: https://github.com/dotnet/cli/issues/7280

==================================================================

Steps to reproduce

dotnet new a console app
dotnet add package

Expected behavior

whitespace between itemgroups etc is preserved

Actual behavior

All blank lines are removed

Environment data

dotnet --info output:

Product Information:
 Version:            2.0.0-preview3-006770
 Commit SHA-1 hash:  78e7163819

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.15063
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.0.0-preview3-006770\

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.0-preview3-25514-02
  Build    : 1b047a04057cec973cfb890fd21f7a639cfcd118


Copied from original issue: dotnet/msbuild#2376

@mishra14
Copy link
Contributor Author

mishra14 commented Aug 1, 2017

I think this is an msbuild issue as NuGet invokes msbuild API's to read a csproj, add items/itemgroups and then save the csproj file.

@mishra14
Copy link
Contributor Author

mishra14 commented Aug 1, 2017

From @rainersigwald on August 1, 2017 23:9

@mishra14 #1036 added a new argument to ProjectRootElement.Open to preserve the existing formatting of the file. Can you opt NuGet into it? That's what CPS did for VS-based edits.

@mishra14
Copy link
Contributor Author

mishra14 commented Aug 1, 2017

I see. I guess NuGet can take this. I will move this issue out.

@mishra14
Copy link
Contributor Author

mishra14 commented Aug 1, 2017

@rainersigwald I dont see -
public static ProjectRootElement Open(string path, bool? preserveFormatting); overload.
Whats the best option for this call?

@rrelyea
Copy link
Contributor

rrelyea commented Aug 2, 2017

Unsure if CLI fixes from NuGet would have a ship vehicle in 15.4... May wait until 15.5.
Happy to go ahead and do this kind of fix in 4.4, as long as we ensure we test it well now.

mishra14 pushed a commit to NuGet/NuGet.Client that referenced this issue Aug 2, 2017
…age (#1602)

Fixing: NuGet/Home#5697

Adding a bool? preserveFormatting to ProjectRootElement.Open call. This preserves the existing formatting in the csproj file.
@mishra14
Copy link
Contributor Author

mishra14 commented Aug 2, 2017

Merged: NuGet/NuGet.Client@d420ac3

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

No branches or pull requests

2 participants