GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Fix Start-PSBuild on WSL if repository was already built on Windows by bergmeister · Pull Request #5346 · PowerShell/PowerShell Conversation
|
|
This should slot in nicely with my tweak to build.psm1 #5341 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I think you need to update this .gitignore file to make it handle the platform specific inc files: I was noticing that Git thought I had a new file with powershell_win.inc. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
… because the file can now optionally end in the runtime prefix.
There was an error while loading. Please reload this page.
|
Thanks. Well spotted, I updated it to ignore now |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Christoph Bergmeister (@bergmeister) Because this ignore rule doesn't apply to anywhere else in the repository, just keeping it simple 😄 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Andy Jordan (@andschwa) My thinking is rather that if there will never be any other |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if ($TypeGen -or -not (Test-Path "$PSScriptRoot/src/System.Management.Automation/CoreCLR/CorePsTypeCatalog.cs")) { | ||
| $incFileName = 'powershell' | ||
| if (-not [string]::IsNullOrEmpty($Runtime)) { | ||
| $incFileName = "$($incFileName)_$($Runtime.Substring(0,3))" # use the first 3 characters only because otherwise dotnet will crash due to the separation characters |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I believe our guidance is to put the comment on a separate line.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
you could replace the seperation character.... not sure it's needed though.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
You're right about the comment. I noticed that only after the commit but I will fix that. The separation character is only for readability because to me powershell_win or powerhell_lin is easier and faster to read than powershellwin or powershelllin
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Looks good with minor comments.
Dongbo Wang (@daxian-dbw) and/or Ilya (@iSazonov) should review as well.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
NB: The build was red because NuGet has a global outage (see here) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| # Append the first 3 characters fo the Runtime only because otherwise dotnet will crash due to the separation characters. The underscore is only for better readability. | ||
| $incFileName = "$($incFileName)_$($Runtime.Substring(0,3))" | ||
| } | ||
| if ($TypeGen -or -not (Test-Path "$PSScriptRoot/TypeCatalogGen/$($incFileName).inc")) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
We use $incFileName).inc so many times so make sense add:
$incFileName = ($incFileName).inc
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Ok, I have addressed that.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I'd prefer to fix the issue more natively like #3870. Also I'm not sure that's the only runtime addiction. Should we clean up if our files contains "#if UNIX"? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…ication as suggested in PR. Tested again that it still works when building on Windows first using 'Start-PSBuild' and then 'Start-PSBuild -Runtime linux-x64' on WSL (ubuntu16)
| # handle TypeGen | ||
| if ($TypeGen -or -not (Test-Path "$PSScriptRoot/src/System.Management.Automation/CoreCLR/CorePsTypeCatalog.cs")) { | ||
| $incFileName = 'powershell.inc' | ||
| if (-not [string]::IsNullOrEmpty($Runtime)) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can you use $Options.Runtime? When -Runtime is not specified, we will figure out the current RID via dotnet --info, which will be captured by $Options.Runtime
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The $Options.Runtime will always be 'NotNullOrEmpty', so maybe you can have:
$incFileName = "powershell_$($Runtime.Substring(0,3)).inc"
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Good idea. Yes, we can use $Options.Runtime indeed instead. I was not aware that you already figure it out automatically when it is not being provided. Shall I maybe add this information as a comment to the $Runtime parameter?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
You mean the -Runtime parameter of Start-PSBuild? Sure you can add a comment there.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| $incFileName = 'powershell.inc' | ||
| if (-not [string]::IsNullOrEmpty($Runtime)) { | ||
| # File name must be different for Windows and Linux to allow build on Windows and WSL. | ||
| # Append the first 3 characters fo the Runtime only because otherwise dotnet will crash due to the separation characters. The underscore is only for better readability. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
characters fo the Runtime
A typo.
otherwise dotnet will crash due to the separation characters
Could you please share more information on this?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for spotting the typo and thanks for coming back about the crash. When I started out I was experimenting with different approaches (one of was to put the inc file into a runtime specific folder) and I actually cannot repro the crash anymore and will therefore use the full $Runtime string instead of the first 3 characters.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if (-not [string]::IsNullOrEmpty($Runtime)) { | ||
| # File name must be different for Windows and Linux to allow build on Windows and WSL. | ||
| # Append the first 3 characters fo the Runtime only because otherwise dotnet will crash due to the separation characters. The underscore is only for better readability. | ||
| $incFileName = "$($incFileName)_$($Runtime.Substring(0,3)).inc" |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Maybe just use powershell_$($Runtime.Substring(0,3)).inc? Otherwise it would beome powershell.inc_xxx.inc
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This change has now been undone since we do not need that logic any more due to the usage of $Options.Runtime
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| # Append the first 3 characters fo the Runtime only because otherwise dotnet will crash due to the separation characters. The underscore is only for better readability. | ||
| $incFileName = "$($incFileName)_$($Runtime.Substring(0,3)).inc" | ||
| } | ||
| if ($TypeGen -or -not (Test-Path "$PSScriptRoot/TypeCatalogGen/$($incFileName)")) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
$($incFileName) can be replaced by $incFileName
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
No, this is one of the gotchas about PowerShell string interpolation because PowerShell allows underscores for variable names. Therefore PowerShell would then look for a variable named incFileName_ instead of incFileName. As a general rule, I always wrap variables in a string inside $() because it also safeguards against cases like calling a property on an object...
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
In the case of "$($incFileName)_xxx.inc", you can replace it with "${incFileName}_xxx.inc". PowerShell support the varialbe syntax ${var name}
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| ( | ||
| [Parameter(Mandatory=$true)] | ||
| [ValidateNotNullOrEmpty()] | ||
| $IncFileName |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should have 'powershell.inc' as the default value for this parameter, so that Start-TypeGen without parameter will continue to work.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I can do that if people actually call Start-TypeGen? I always use the -ResGen swich on Start-PSBuild because the reason why I need update ResGen is because I need to build anyway. Instead of having the default, why not call New-PSOptions and grab the determined Runtime, which is what Start-PSBuild does as well.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It's not commonly needed, but when debugging anything about the type catalog, it's handy to just run Start-TypeGen without building the rest of the projects. For that purpose, a simple default value like powershell.inc would be sufficient, no need to call New-Options to figure out the runtime.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
And a minor comment: the variable name you used in the rest of this function is incFileName, maybe it can be changed to IncFileName.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| Push-Location "$PSScriptRoot/src/Microsoft.PowerShell.SDK" | ||
| try { | ||
| $ps_inc_file = "$PSScriptRoot/src/TypeCatalogGen/powershell.inc" | ||
| $ps_inc_file = "$PSScriptRoot/src/TypeCatalogGen/$($incFileName)" |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
$($incFileName) can be replaced by $incFileName
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
In this case we can do that but what do you think about my comment above where this is not always possible?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
PowerShell support this syntax for variable: ${var name}, so you can use "${varname}_xxx.inc" in that case.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I'll address the comments next Monday when I'm back from travelling. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
… to be necessary.
…rmined if the $Runtime is not being provided.
|
Dongbo Wang (@daxian-dbw) Thanks for your useful feedback. I have addressed all issues and left comments there. But basically the 2 remaining questions are:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| # Handle TypeGen | ||
| # .inc file name must be different for Windows and Linux to allow build on Windows and WSL. | ||
| $incFileName = "powershell_$($Options.Runtime).inc" | ||
| if ($TypeGen -or -not (Test-Path "$PSScriptRoot/TypeCatalogGen/$($incFileName)")) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
$($incFileName)
Subexpression is not needed here, you can just use $incFileName
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| # Append the first 3 characters fo the Runtime only because otherwise dotnet will crash due to the separation characters. The underscore is only for better readability. | ||
| $incFileName = "$($incFileName)_$($Runtime.Substring(0,3)).inc" | ||
| } | ||
| if ($TypeGen -or -not (Test-Path "$PSScriptRoot/TypeCatalogGen/$($incFileName)")) { |
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
In the case of "$($incFileName)_xxx.inc", you can replace it with "${incFileName}_xxx.inc". PowerShell support the varialbe syntax ${var name}
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| ( | ||
| [Parameter(Mandatory=$true)] | ||
| [ValidateNotNullOrEmpty()] | ||
| $IncFileName |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It's not commonly needed, but when debugging anything about the type catalog, it's handy to just run Start-TypeGen without building the rest of the projects. For that purpose, a simple default value like powershell.inc would be sufficient, no need to call New-Options to figure out the runtime.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| Push-Location "$PSScriptRoot/src/Microsoft.PowerShell.SDK" | ||
| try { | ||
| $ps_inc_file = "$PSScriptRoot/src/TypeCatalogGen/powershell.inc" | ||
| $ps_inc_file = "$PSScriptRoot/src/TypeCatalogGen/$($incFileName)" |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
PowerShell support this syntax for variable: ${var name}, so you can use "${varname}_xxx.inc" in that case.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Christoph Bergmeister (@bergmeister) For the two questions, I answered them in the corresponding comment threads: #5346 (comment) and #5346 (comment) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Use default value for Start-TypeGen for convenience and minor syntax changes. Tested again that it still works when building on Windows first and then on WSL
|
Dongbo Wang (@daxian-dbw) Thanks for the review. I have addressed your comments. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks Christoph Bergmeister (@bergmeister)!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…owerShell#5346) Replace the static `powershell.inc` filename with a name based on the current RID, so that the build doesn't confuse when running in the same local repository on WSL.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Building PowerShell Core on WSL generates error
There was an error while loading. Please reload this page.