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

fix build in vscode #5453

Merged
merged 5 commits into from Nov 15, 2017
Merged

fix build in vscode #5453

merged 5 commits into from Nov 15, 2017

Conversation

SteveL-MSFT
Copy link
Member

@SteveL-MSFT SteveL-MSFT commented Nov 14, 2017

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

Copy link
Member

@adityapatwardhan adityapatwardhan left a 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) {
Copy link
Member

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.

Copy link
Member Author

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) {
Copy link
Member

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."?

Copy link
Member Author

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
Copy link
Member

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"

Copy link
Member Author

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" `
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Will fix

@rkeithhill
Copy link
Collaborator

rkeithhill commented Nov 15, 2017

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 $msCompile problem matcher at the moment but that's an issue for VSCode. BTW why does the build task specify -Output ./debug? Doesn't it put the output in a reasonable location by default? Also, any reason not to use Windows PowerShell on Windows? If so, we can always set the executable to pwsh.exe on Windows.

Also, I wonder if we should specify a tag for testing within VSCode - perhaps CI? I think using CI would get rid of the failures I see due to not running VSCode as admin.

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.

@SteveL-MSFT
Copy link
Member Author

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
"label": "Clean Build",
"type": "shell",
"command": "Import-Module ${workspaceFolder}/build.psm1; Start-PSBuild -Clean",
"problemMatcher": []
Copy link
Collaborator

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?

{
"label": "Test",
"type": "shell",
"command": "Import-Module ${workspaceFolder}/build.psm1; Start-PSPester -Path ${workspaceFolder}/test",
Copy link
Collaborator

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.

Copy link
Member Author

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.

@SteveL-MSFT
Copy link
Member Author

@rkeithhill to answer some of your questions:

  1. the debug folder is used as it's included in .gitignore
  2. since this tasks.json is only used to build pwsh, I think it's preferable to depend on pwsh rather than Windows PowerShell (the rest of the tooling expects it)
  3. -Clean cleans then builds

"problemMatcher": "$msCompile"
}
]
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

New line.

Copy link
Member Author

Choose a reason for hiding this comment

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

will add

Copy link
Collaborator

@iSazonov iSazonov left a 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)",
Copy link
Collaborator

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.

Copy link
Collaborator

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

Copy link
Member Author

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

Copy link
Collaborator

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Will add. Thanks!

@rkeithhill
Copy link
Collaborator

rkeithhill commented Nov 15, 2017

I think I'm caught up to your version of tasks.json but when I execute the Rebuild task (formerly Clean Build), I'm getting this error:

PowerShell output: c:\Users\Keith\GitHub\rkeithhill\PowerShell\debug
WARNING: Run Sync-PSTags to update tags
Unable to load file: "c:\Users\Keith\GitHub\rkeithhill\PowerShell\debug"
Execution of { & "~/.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" `
            --set-requested-execution-level "asInvoker" --set-version-string "LegalCopyright" "(C) Microsoft Corporation.  All Rights Reserved." } failed with exit code 1

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.

@daxian-dbw daxian-dbw merged commit 2f8e691 into PowerShell:master Nov 15, 2017
@SteveL-MSFT SteveL-MSFT deleted the vscode-build branch November 15, 2017 20:09
@SteveL-MSFT SteveL-MSFT restored the vscode-build branch November 21, 2017 18:49
@SteveL-MSFT SteveL-MSFT deleted the vscode-build branch October 26, 2018 21:34
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.

None yet

5 participants