Skip to content

Ignore global.json in script folder #573

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

Merged
merged 7 commits into from
Aug 11, 2020
Merged

Conversation

seesharper
Copy link
Collaborator

@seesharper seesharper commented Aug 11, 2020

This PR fixes a bug that comes into play if the user has a global.json file located in the script folder that is incompatible with dotnet-script. We are pretty much tied to the 3.1 sdk since dotnet-script is a netcoreapp3.1. I have seen this bug in the past also when trying to execute a script in a folder that resolves the "wrong" sdk through a global.json file.

The solution to this is to execute dotnet restore with the temp folder as the working directory. By temp folder I mean the folder where the generated csproj file is located.

Also added a global.json file to this repo as it made local testing a little bit difficult now having the .Net 5 prerelease SDK's installed. The pinned version is the same 3.1 sdk we install on the build servers.

Finally also added a test that verifies that a script can run even if we have an "invalid" global.json file

This should fix #571 👍

@@ -470,7 +479,7 @@ private static string CreateTestScript(string scriptFolder)

private static void CreateTestPackage(string packageLibraryFolder)
{
ProcessHelper.RunAndCaptureOutput("dotnet", "new classlib -n NuGetConfigTestLibrary", packageLibraryFolder);
ProcessHelper.RunAndCaptureOutput("dotnet", "new classlib -n NuGetConfigTestLibrary -f netstandard2.0", packageLibraryFolder);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is needed if you have the .Net 5 SDK installed since that version no longer defaults to netstandard2.0

@seesharper seesharper requested a review from filipw August 11, 2020 09:16
global.json Outdated
@@ -0,0 +1,5 @@
{
"sdk": {
"version": "3.1.102"
Copy link
Member

Choose a reason for hiding this comment

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

you can add here "rollForward":"latestFeature" to avoid explicit install

Copy link
Member

@filipw filipw left a comment

Choose a reason for hiding this comment

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

yes that makes sense to me -thanks

@seesharper
Copy link
Collaborator Author

Great. Added rollForward":"latestFeature . Merging this then 👍😀

@seesharper seesharper merged commit f4ea82a into master Aug 11, 2020
@seesharper seesharper deleted the bugfix-working-directory branch August 11, 2020 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"global.json" interferes with "dotnet restore" of script
2 participants