-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Update PowerShell to build with .NET Core SDK 2.1.300-rc1-008662 #6718
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
Update PowerShell to build with .NET Core SDK 2.1.300-rc1-008662 #6718
Conversation
d007b1a to
f585424
Compare
8bdf8a5 to
d3c5edf
Compare
|
Working with dotnetcore team to figure out crossgen issue. Temporarily turned |
3e071a6 to
1e60cd9
Compare
|
A bunch of webcmdlet tests are failing because the User-Agent string has a regression in dotnetcore 2.1-preview2. Looks like they already fixed it though. |
6eae8be to
7b5c542
Compare
|
Locally I tried use the older HttpClientHandler adding AppContext.SetSwitch("System.Net.Http.UseSocketsHttpHandler", false);and other web cmdlet tests failed. It seems better not to use the former HttpClientHandler and investigate current test failures. @markekraus Could you please help? We could set pending for User-Agent tests until we move to .Net Core 2.1 RC. |
|
I see that another test completes abnormally.
I'm fixing the test, but it seems that it can cause problems in scripts and not only in this case because other APIs can also be extended. |
|
I looked into the authorization issues. It looks like there is a change in HttpClient's behavior between 2.0 and 2.1 WRT authorization headers on redirect. using this code in 6.0.2 and a build from @iSazonov branch: $Handler = [System.Net.Http.HttpClientHandler]::new()
$client = [System.Net.Http.HttpClient]::new($Handler)
$req = [System.Net.Http.HttpRequestMessage]::new()
$req.Headers.Add('Authorization','test')
$req.RequestUri = 'https://httpbin.org/redirect-to?url=https://httpbin.org/get'
$res = $client.SendAsync($req).GetAwaiter().GetResult()
$res.Content.ReadAsStringAsync().GetAwaiter().GetResult()in 6.0.2 (using dotnet 2.0): {
"args": {},
"headers": {
"Authorization": "test",
"Connection": "close",
"Host": "httpbin.org"
},
"origin": "173.239.232.139",
"url": "https://httpbin.org/get"
}in the build of this PR (dotnet 2.1): {
"args": {},
"headers": {
"Connection": "close",
"Host": "httpbin.org"
},
"origin": "173.239.232.139",
"url": "https://httpbin.org/get"
}So it appears HttpClient no longer sends Authorization headers on redirect. We can handle this in the web cmdlets with some change in logic. But I'd like to find out if this is a regression or |
|
@markekraus Many thanks! Could you please look https://stackoverflow.com/questions/28564961/authorization-header-is-lost-on-redirect ? My understanding is that a http client remove authorization headers by default because of security. |
ac8906f to
12da43b
Compare
|
@iSazonov Yes. In .NET Framework (which is what that link is about) HttpClient did strip authorization by default. You can see this for yourself in Windows PowerShell 5.1 with the same code after running In .NET Core 1.0-2.0, however, Authorization was not stripped by default. Code was added to the cmdlets to handle that. By default, we intercept the response if the authorization header is present. The pwsh web cmdlets do that by default and it can be overridden with If the change in 2.1 is |
|
@iSazonov @SteveL-MSFT ugh.. the change in the https://docs.microsoft.com/en-us/dotnet/api/system.string.contains?view=netcore-2.1 I hope there is something we can point users to in our release notes for 6.1 to changes in 2.1 APIs. |
|
Clear Authorization Headers on Redirect dotnet/corefx#26864 |
|
@iSazonov thanks for finding that. It seems clear this is an intentional change so we will need to modify or logic. The good news is that the current way was fragile (we fixed 2 issues with it since 6.0.0) and since it was default it ran more often. Now we can rely on .NET and the fragile code will run less often. |
cff8bdc to
4ec4f91
Compare
|
created #6728 to track the authorization logic changes needed. |
0fa3ed9 to
1f4ea23
Compare
|
My thought is that we shouldn't move to dotnetcore until PSCore6+2.1 is as good or better than current PSCore6 build. So I would wait until the fixes are available to pick up in this PR than get into a state where some things work and some things don't and we accidentally miss something on release of 6.1. I would be fine moving ahead to something newer than 2.1-Preview2 since it appears dotnetcore is moving towards RC and the window of opportunity to get them to fix issues in 2.1 before they declare GA is getting smaller. For this reason, I prefer not to mark tests as |
1f4ea23 to
f4bbdf2
Compare
|
@daxian-dbw Could you please review the important PR too and merge? |
| "System.Globalization.Calendars", | ||
| "System.Globalization.Extensions", | ||
| "System.IO", | ||
| "System.IO.Compression", |
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.
It seems System.ComponentModel.Composition.dll is gone. Then it should be removed from this list now.
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.
A note about Microsoft.CodeAnalysis.VisualBasic.dll we added from the Add-Type refactoring. Since we plan to remove the VB support, we shouldn't add that dll in this list.
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 take care of this #Closed.
| <add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" /> | ||
| <add key="nuget.org" value="https://api.nuget.org/v3/index.json" /> | ||
| </packageSources> | ||
| </configuration> |
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.
This nuget.config file doesn't introduce a new feed. Do we need it only because we need to try dotnet-core before nuget.org?
| $Script:Options.Runtime -ne $Runtime -or ## Last build wasn't for the required RID | ||
| $Script:Options.Configuration -ne $Configuration -or ## Last build was with configuration other than 'Release' | ||
| $Script:Options.Framework -ne "netcoreapp2.0") ## Last build wasn't for CoreCLR | ||
| $Script:Options.Framework -ne "netcoreapp2.1") ## Last build wasn't for CoreCLR |
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 see other places using netcoreapp2.0. They all need to be updated.
PS:103> dir *.psm1 -Recurse | sls -SimpleMatch netcoreapp2.0
test\tools\OpenCover\OpenCover.psm1:627: [parameter()]$PowerShellExeDirectory =
"${script:psRepoPath}/src/powershell-win-core/bin/CodeCoverage/netcoreapp2.0/win7-x64/publish",
tools\packaging\packaging.psm1:2221: New-MSIPackage -Verbose -ProductCode (New-Guid) -ProductSourcePath
'.\src\powershell-win-core\bin\Debug\netcoreapp2.0\win7-x64\publish' -ProductTargetArchitecture x64 -ProductVersion
'1.2.3'
build.psm1:560: # publish netcoreapp2.0 reference assembliesThere 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.
Fixed. #Closed.
build.psm1
Outdated
| throw "crossgen is not available for this platform" | ||
| } | ||
|
|
||
| $dotnetRuntimeVersion = $dotnetCLIRequiredVersion -match "(\d\.\d)\..*" | ForEach-Object { $matches[1] } |
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.
This will give us the Major.Minor version of the sdk, not the runtime. The sdk version is different from the runtime version, e.g. we use sdk 2.1.4 currently with runtime version 2.0. It may happen in future that sdk moved to 2.2 while we are still using 2.1 runtime.
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.
Seems we need review this after .Net Core 2.1 release because it introduce new policy - always use latest version. It is still not work for Preview versions. And seems they want adjust this versions for simplicity.
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.
It is still not work for Preview versions.
What is not working for preview versions?
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 problem we had in CI w/o this is that we pick up the first version that matches which was crossgen 2.2 (some preview version) which is not compatible with the 2.1 built binaries.
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 wonder how come we have the 2.2 runtime packages in our CI runs ... I wish we can figure this out.
This line of script gets the Major.Minor of the sdk version, not the runtime version, which is not what we really want (not future-proof). Maybe explicitly use 2.1* for now (which is also not future-proof, but at least intuitive than the regex matching)?
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.
Perhaps we should rename the variable to $dotnetSdkVersion. Keeping this regex would mean that when we move to 2.2, but there's a 2.3 preview out we won't be broken.
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.
It also means that when we move to sdk 2.2 but still building against runtime 2.1 (similar to what we have today: sdk 2.1.4, runtime 2.0), we will be broken.
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.
Using dotnet --list-runtimes shows Microsoft.NETCore.App 2.1.0-rc1-26423-06 which matches the runtime version of crossgen we need. So perhaps we can use dotnet --list-runtimes and select the newest one and match that runtime version to find appropriate crossgen.
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.
We can use $Script:Options.Framework to get the runtime version. The framework will always be netcoreapp2.1 until we update it again.
$dotnetRuntimeVersion = $script:Options.Framework -replace 'netcoreapp'
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.
What is not working for preview versions?
I meant that .Net Core starting with 2.0 has new model and always uses latest runtime versions (roll-forward minor versions) with dotnet publish but it is not working for preview versions.
| # Get the CrossGen.exe for the correct runtime with the latest version | ||
| $crossGenPath = Get-ChildItem $script:Environment.nugetPackagesRoot $crossGenExe -Recurse | ` | ||
| Where-Object { $_.FullName -match $crossGenRuntime } | ` | ||
| Where-Object { $_.FullName -match $dotnetRuntimeVersion } | ` |
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.
Is this really necessary? I didn't try on Linux and macOS, but on Windows, the 2.1 folder is the first one after sort (I have 2.0.6, 2.0.5 and 2.0.0 runtime package installed):
PS:107> dir crossgen.exe -Recurse | ? FullName -Match win-x64 | sort -Property FullName -Descending | select -First 1
Directory: C:\Users\dongbow\.nuget\packages\runtime.win-x64.microsoft.netcore.app\2.1.0-rc1-26423-06\tools
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 4/23/2018 9:07 AM 2916176 crossgen.exe
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.
This was happening in CI. #Closed.
…sFromRAR' when moving to new sdk
|
We also need to update the versions of the dotnet NuGet packages referred by Note that, we should pick the |
|
LGTM.
|
|
@iSazonov I'm not familiar with the issue regarding web cmdlet proxy tests and workaround for curl. You probably have more context, so can you please open a tracking issue for that? As to packaging review, do you have any specific concerns about how this change would affect packaging? @SteveL-MSFT, @adityapatwardhan and @markekraus, since new commits were pushed after you signed off, could you please take another look at this PR? Thanks! |
|
@daxian-dbw I agree with starting a release build after this is merged. |
|
About the Visual Studio build, I don't know if it will still work after this merge ... @TravisEz13 Does VS2017 allow configuring which dotnet sdk to use? |
|
For Visual Studio you cannot specify the SDK. |
|
This has been a long thread, @iSazonov can you summarize the proxy issue with the webcmdlet tests? I changed the tests as they were originally just wrong and incomplete. I think we should probably remove the tests for http_proxy env var which we skip on Windows because that is a side effect of corefx taking dependency on libcurl for non-Windows and not something supported explicitly by corefx nor the webcmdlets. |
|
Currently I agree to remove this proxy tests. But I'll look this in depth only tomorrow. If I'll discover something important I'll open new tracking Issue. |
|
The PR LGTM. |
SteveL-MSFT
left a comment
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
|
PR merged. Thanks everyone for getting this done! |
|
Thanks everyone for this work! Maybe it's a good experience of working together. |
PR Summary
Build.psm1to work with 2.1osx-x64as the current build logic expects 10.12 and breaks running on 10.13 system.Test updates:
Pendingdue to change in corefxPR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.[feature]if the change is significant or affects feature tests