-
-
Notifications
You must be signed in to change notification settings - Fork 20
fix(nuget): move global.json aside during dotnet setversion
#820
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,10 @@ | ||
| import { existsSync, readFileSync, readdirSync, writeFileSync } from 'fs'; | ||
| import { | ||
| existsSync, | ||
| readFileSync, | ||
| readdirSync, | ||
| renameSync, | ||
| writeFileSync, | ||
| } from 'fs'; | ||
| import { join } from 'path'; | ||
|
|
||
| import { TargetConfig, TypedTargetConfig } from '../schemas/project_config'; | ||
|
|
@@ -78,6 +84,15 @@ export class NugetTarget extends BaseTarget { | |
| } | ||
|
|
||
| if (hasExecutable(NUGET_DOTNET_BIN)) { | ||
| // `dotnet-setversion` operates in cwd and will pickup global.json, | ||
| // which breaks if the pinned SDK isn't installed on the craft runner. | ||
| // See: https://github.com/getsentry/craft/issues/819 | ||
| const globalJsonPath = join(rootDir, 'global.json'); | ||
| const globalJsonBackup = `${globalJsonPath}.craft-bak`; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably use a unique name per instance to avoid any potential clashes but since the probabiliy is very low, I'll merge it as it. Would appreciate a follow up to fix this tho.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No worries - follow up PR: |
||
| const globalJsonMoved = existsSync(globalJsonPath); | ||
| if (globalJsonMoved) { | ||
| renameSync(globalJsonPath, globalJsonBackup); | ||
| } | ||
| try { | ||
| const result = await spawnProcess( | ||
| NUGET_DOTNET_BIN, | ||
|
|
@@ -99,6 +114,10 @@ export class NugetTarget extends BaseTarget { | |
| logger.debug( | ||
| 'dotnet-setversion not available, falling back to manual edit', | ||
| ); | ||
| } finally { | ||
| if (globalJsonMoved) { | ||
| renameSync(globalJsonBackup, globalJsonPath); | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.