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

Create tracking file when user-profile nuget.config does not exist #4338

Merged
merged 7 commits into from Nov 24, 2021

Conversation

zivkan
Copy link
Member

@zivkan zivkan commented Nov 15, 2021

Tip for reviewer: remove the first commit when viewing the diff.

Bug

Fixes: NuGet/Home#11387

Regression? No

Description

PR Checklist

  • PR has a meaningful title

  • PR has a linked issue.

  • Described changes

  • Tests

    • Automated tests added
    • OR
    • Test exception
    • OR
    • N/A
  • Documentation

    • Documentation PR or issue filled
    • OR
    • N/A

@zivkan zivkan requested a review from a team as a code owner November 15, 2021 23:01
@zivkan
Copy link
Member Author

zivkan commented Nov 16, 2021

I just realized this PR will cause problems for customers who started from a clean machine since #3907 shipped, and do not want to use nuget.org. If this PR is merged as-is, they will have nuget.org added to their user-profile one time.

Since chocolatey claim that their fix has been released, perhaps we should just close this PR. I believe that Windows PowerShell (5.1)'s Install-Module will still create an empty nuget.config, but PowerShell 7 (and I believe 6, but that's already out of support) use an updated NuGet.Configuration which adds nuget.org as a source.

So, this will be an on-going issue for anyone who uses PowerShell 5.1's Install-Module before using nuget.exe, dotnet CLI or Visual Studio, but the number of customers doing this appear to be small. Therefore merging this PR might negatively affect more customers than the number of customers who will be helped.

@JonDouglas thoughts?

@JonDouglas
Copy link

This seems like a net positive PR. I don't really see the downsides here as this issue crops up time from time and looks like this may help future proof it.

Copy link
Contributor

@dominoFire dominoFire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments. Looks good.

@zivkan zivkan force-pushed the dev-zivkan-default-package-source branch 3 times, most recently from bd0da6d to 3b33e14 Compare November 20, 2021 01:42
Copy link
Contributor

@donnie-msft donnie-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A consideration is simply telling the user when these files are written or overwritten.
That may require piping the ILogger all the way down from places like RestoreArgs.cs. But as a user, might I like to know when files are written, at least at certain verbosities?

<configuration>
</configuration>";

var nugetConfigPath = "NuGet.Config";
SettingsTestUtils.CreateConfigurationFile(nugetConfigPath, Path.Combine(mockBaseDirectory, "TestingGlobalPath"), config);
string nugetConfigPath = "NuGet.Config";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Literals should be implicit types

// Settings.LoadSettings' useTestingGlobalPath will use a subdirectory, instead of machine configuration, to allow for testing.
string mockUserProfileDirectory = Path.Combine(mockSolutionDirectory, "TestingGlobalPath");

string emptyConfig = @"<?xml version=""1.0"" encoding=""utf-8""?>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Literals should be implicit types

File.Exists(nugetConfigPath).Should().BeTrue();
var actual = SettingsTestUtils.RemoveWhitespace(File.ReadAllText(nugetConfigPath));
var expected = SettingsTestUtils.RemoveWhitespace(@"<?xml version=""1.0"" encoding=""utf-8""?>
string emptyConfig = @"<?xml version=""1.0"" encoding=""utf-8""?>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Literals should be implicit types


actual.Should().Be(expected);
}
string nugetConfigPath = "NuGet.Config";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Literals should be implicit types

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