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
fix build in vscode #5453
fix build in vscode #5453
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
build.psm1
Outdated
Write-Verbose "Release version: $ReleaseVersion" -Verbose | ||
|
||
$pwshPath = $Options.Output | ||
if ($Environment.IsWindows) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole RCEdit
work is in if ($Environment.IsWindows) {
block (see line 561), so no need to split the code path here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, forgot rcedit only applied to Windows, will fix
build.psm1
Outdated
@@ -569,10 +569,28 @@ Fix steps: | |||
$ReleaseVersion = $ReleaseTagToUse | |||
} else { | |||
$ReleaseVersion = (Get-PSCommitId) -replace '^v' | |||
$fileVersion = $ReleaseVersion.Split("-")[0] | |||
} | |||
if (!$ReleaseVersion) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add a comment about "In vscode, depending on where you started it from, it may not get the git commit id so it ends up empty. Add a default value to use."?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do
build.psm1
Outdated
$fileVersion = "6.0.0" | ||
} | ||
|
||
Write-Verbose "Release version: $ReleaseVersion" -Verbose |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use log
like rest of the file. I think it's better to make the message more specific on the RCEdit operation, like "Embed the icon resource to pwsh.exe, use release version: $ReleaseVersion"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll just remove this, only needed it to figure out why it wasn't working
Start-NativeExecution { & "~/.rcedit/rcedit-x64.exe" "$($Options.Output)" --set-icon "$PSScriptRoot\assets\Powershell_black.ico" ` | ||
--set-file-version $ReleaseVersion --set-product-version $ReleaseVersion --set-version-string "ProductName" "PowerShell Core 6" ` | ||
Start-NativeExecution { & "~/.rcedit/rcedit-x64.exe" $pwshPath --set-icon "$PSScriptRoot\assets\Powershell_black.ico" ` | ||
--set-file-version $fileVersion --set-product-version $ReleaseVersion --set-version-string "ProductName" "PowerShell Core 6" ` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$fileVersion
is not set when $ReleaseTagToUse
exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will fix
You might want to try this tasks.json: {
"version": "2.0.0",
"windows": {
"options": {
"shell": {
"executable": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
"args": [
"-NoProfile",
"-ExecutionPolicy",
"Bypass",
"-Command"
]
}
}
},
"linux": {
"options": {
"shell": {
"executable": "/usr/bin/pwsh",
"args": [
"-NoProfile",
"-Command"
]
}
}
},
"osx": {
"options": {
"shell": {
"executable": "/usr/local/bin/pwsh",
"args": [
"-NoProfile",
"-Command"
]
}
}
},
"tasks": [
{
"label": "Bootstrap",
"type": "shell",
"command": "Import-Module ${workspaceFolder}/build.psm1; Start-PSBootstrap",
"problemMatcher": []
},
{
"label": "Clean Build",
"type": "shell",
"command": "Import-Module ${workspaceFolder}/build.psm1; Start-PSBuild -Clean",
"problemMatcher": []
},
{
"label": "Build",
"type": "shell",
"command": "Import-Module ${workspaceFolder}/build.psm1; Start-PSBuild -Output ${workspaceFolder}/debug",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": "$msCompile"
},
{
"label": "Test",
"type": "shell",
"command": "Import-Module ${workspaceFolder}/build.psm1; Start-PSPester -Path ${workspaceFolder}/test -Tag CI",
"group": {
"kind": "test",
"isDefault": true
},
"problemMatcher": "$pester"
}
]
} There seems to be an issue with the Also, I wonder if we should specify a tag for testing within VSCode - perhaps I can submit this as a PR if you'd like or if you just want to take it and run - that's fine too. |
I'll add a slightly modified version of @rkeithhill 's tasks.json. Thanks for that! |
added v2.0.0 tasks.json thanks to Keith Hill
.vscode/tasks.json
Outdated
"label": "Clean Build", | ||
"type": "shell", | ||
"command": "Import-Module ${workspaceFolder}/build.psm1; Start-PSBuild -Clean", | ||
"problemMatcher": [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doh! I forgot to put the $msCompile problem matcher here. I could be wrong about this but Start-PSBuild -Clean doesn't just clean. It cleans first and then builds, right?
.vscode/tasks.json
Outdated
{ | ||
"label": "Test", | ||
"type": "shell", | ||
"command": "Import-Module ${workspaceFolder}/build.psm1; Start-PSPester -Path ${workspaceFolder}/test", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should consider adding the -Tag CI
parameter here. Running VSCode as admin is not something most folks do and if you run these tests not elevated, you get a lot of failures. You could also add two tasks - one that does a full test run and another that tests just the CI tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I think I'll remove this task as intent is people run CI + Feature (which is default), but you are right that the tests expect user to be elevated and, in general, shouldn't be running vscode elevated.
15b6e48
to
c1f0bea
Compare
@rkeithhill to answer some of your questions:
|
.vscode/tasks.json
Outdated
"problemMatcher": "$msCompile" | ||
} | ||
] | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will add
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SteveL-MSFT @rkeithhill Thanks for the great PR!
{ | ||
"label": "Build", | ||
"type": "shell", | ||
"command": "Import-Module ${workspaceFolder}/build.psm1; Start-PSBuild -Output (Join-Path ${workspaceFolder} debug)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Can you add the same parameter to the Clean Build
task above? Also, Clean Build
reads a little awkward. What if we called this task Rebuild
? On VS at least, that implies Clean, then Build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW I was just going to warn you about this issue when I saw you not only already knew about it but solved it. 👍 Also, I tagged onto this VSCode issue on the $mscompile problem matcher not working - microsoft/vscode#34660
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will add to Clean Build
which I think is named fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SteveL-MSFT I got a response from the VSCode team on the $mscompile issue. All we need to do is add the command line arg - /property:GenerateFullPaths=true
. I tried putting this around line 485:
$Arguments += "/property:GenerateFullPaths=true"
And it works! There may be other places where this arg needs to be provided.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will add. Thanks!
I think I'm caught up to your version of tasks.json but when I execute the
Are you getting this error? FWIW I get this error from the command line so maybe my source is in a bad state. UPDATE: Ah nevermind, I see you're making a tweak to that very part of build.psm1. I'll hang tight for the PR to be merged. |
There were several issues:
In vscode, depending on where you started it from, it may not get the git commit id so it ends up empty. Add a default value to use.
From the console, the commit id was typically in a form that is not parse-able as a fileversion. Fix is to chop off everything right of the dash.
It also seems that building from the console and building from vscode, the output path may or may not include
pwsh
, however, rcedit needs the actual executable in the path.Fix #5440