-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Move powershell to .NET Core 2.0 #3556
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
Conversation
appveyor.yml
Outdated
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 don't want to cache these at all?
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't we clear the cache with a REST call instead of this change?
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.
There is also a language to describe when to clear the cache https://www.appveyor.com/docs/build-cache/#cache-dependencies
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.
As I mentioned in the description:
Note that the
-cacheoption is removed from appveyor.yml, but it probably should be added back after this PR is merged.
I planned to added it back after this PR gets merged, and add one more directory path: %HOMEDRIVE%%HOMEPATH%\.dotnet. dotnet-cli 2.0.0 depends on such a folder 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.
@TravisEz13 talked to me offline and it turns out it's quite easy to invalidate the cache, I will do that.
507087e to
7f065f0
Compare
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 comment would be nice - because 1000 seems like a more reasonable value.
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.
Comment added.
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 don't think this is a good or useful test - a better test would sample for some expected members.
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.
Change the test to sample for 3 members: a, CreateNode, CreateElement.
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 probably shouldn't delete !CORECLR code in the PR.
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 class is added back.
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 thought registry apis would throw on Unix - so why is this changed?
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.
SafeRegistryHandle is used for transactioned registry, which is not enabled in powershell core. Actually the file SafeRegistryHandle.cs should be excluded from building powershell core.
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.
Why is this deleted? If it's Windows PowerShell only now - it should be a different PR.
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.
Oh, I see, you just moved this type, but it's hard to see that for sure. Can it stay in the same place to make it easier to see if anything changed - and if it should move, do that in another refactoring PR?
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 I make this an exception? DataRow/DataRowView adapters were enabled in MshObject.cs when I was working on the first cut of refactoring to enable the build. ExtraAdapter.cs contains the adapters that are not supported in powershell core and is excluded from the build, that's why I moved those 2 adapters to CoreAdatper.cs.
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.
Never mind, I will revert this change, as I didn't add any tests for the DataRow/DataRowView adapters anyway.
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.
So this code just moved files too? Again, it's hard to tell, and reviewing this for the first time, some of it is weird, like ProgramFiles is /bin, but ProgramFilesX86 is /sur/bin. Weird.
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 code is moved from System.Management.Automation.Environment to SMA.Platform because the former class is completely removed because all environment members we extended now come back in System.Environment. Maybe we need to open a bug to review all if/defs and Unix specific code? -- #3565 is opened.
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.
predicted [](start = 16, length = 9)
predictable
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.
Fixed.
|
@vors - can you review AddType.cs? |
- Fix Start-Sleep test - Delay initializing PowerShellGet tests until they are actually about to run
…ageManagement depends on it
WaitHandle.WaitOne(milliseconds, exitContext) is not accurate. The wait time varies from 980ms to 1020ms in my observation. I change our test to check the wait time to be greater than 950ms.
d7e74bb to
e00a2b5
Compare
|
@TravisEz13 @lzybkr @vors comments have been addressed, could you please continue the review? Thanks! |
vors
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.
This is soooo good! 🎉
I'm signing up mostly on the Add-Type changes with minor comments.
| } | ||
|
|
||
| # add 'x' permission when building the standalone application | ||
| # this is temporary workaround to a bug in dotnet.exe, tracking by dotnet/cli issue #6286 |
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.
that's a pretty hilarious bug
|
|
||
| image: Visual Studio 2015 | ||
|
|
||
| # cache version - netcoreapp.2.0.0-preview1-001913-00 |
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.
Should it be '005724' ?
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.
005724 is the build of dotnet-cli we are currently using, but the netcoreapp version is actually 2.0.0-preview1-001913-00.
|
|
||
| // We look up in reference/framework only when it's for resolving reference assemblies. | ||
| // In case of 'Add-Type -AssemblyName' scenario, we don't attempt to resolve against framework assemblies because | ||
| // 2. Explicitly loading a framework assembly usually is not necessary in PowerShell Core. |
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.
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.
Good catch. Will fix.
| /// </summary> | ||
| private static PortableExecutableReference[] InitDefaultRefAssemblies() | ||
| { | ||
| var defaultRefAssemblies = new List<PortableExecutableReference>(150); |
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 don't like this hardcoded value. Maybe just leave it to a default?
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.
Currently, netcoreapp2.0 comes with 137 reference assemblies, and that's why I choose 150 as the default value. I will add a comment.
By default, the capacity of List is 0, and it increases the size as you add more items. So if the size is roughly known, it's better to specify.
|
|
||
| // Ignore some specified reference assemblies | ||
| string fileName = PathType.GetFileName(resolvedAssemblyPath); | ||
| if (s_refAssemblyNamesToIgnore.Value.Contains(fileName)) { continue; } |
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.
Lets add WriteVerbose() here about the ignoring the file names.
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 it.
| <PackageReference Include="System.ServiceModel.Security" Version="4.4.0-beta-25205-01" /> | ||
| <PackageReference Include="System.Text.Encodings.Web" Version="4.4.0-preview1-25204-02" /> | ||
| <PackageReference Include="System.Threading.AccessControl" Version="4.4.0-preview1-25204-02" /> | ||
| <PackageReference Include="System.Private.ServiceModel" Version="4.4.0-beta-25205-01" /> |
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 double check that?
As we mentioned in https://github.com/PowerShell/PowerShell/tree/master/src/Microsoft.PowerShell.SDK
This second set includes packages that we do not necessarily require at compile-time, but must provide for our users at runtime. For example, we include the library System.Runtime.Serialization.Json.dll so that users of PowerShell can utilize its types and methods, even though PowerShell does not directly depend on the library.
I don't know much about the netstandart 2.0 model, but it's suspicious that we removing so many of them.
This list should be our SDK surface (subset of dotnet that we are promising to all applications).
It should not rely on our cross dependencies in the project.
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.
netcoreapp2.0 now includes most of those dependencies by default, and that's why many get removed from SDK.csproj. Now I'm inclined to use SDK.csproj as:
- meta project that references other projects
- meta project that references those packages that are not directly depended by powershell projects.
|
@TravisEz13 @vors @lzybkr Thanks for the review! |
|
@daxian-dbw Great work! Thanks! |
This change moves powershell to .NET Core 2.0. Major changes are:
netcoreapp2.0. We are usingmicrosoft.netcore.app-2.0.0-preview1-001913-00, which is from dotnet-core build 4/4/17. We cannot targetnetstandard2.0because the packagesSystem.Reflection.EmitandSystem.Reflection.Emit.Lightweight, which are needed for powershell class, cannot be referenced when targetingnetstandard2.0.Note that theThe-cacheoption is removed fromappveyor.yml, but it probably should be added back after this PR is merged.-cachesection is added back and specified to depend onappveyor.yml, so the cache will be invalidated ifappveyor.ymlis changed. Thanks to @TravisEz13netcoreappreference assemblies with powershell to fix the issues inAdd-Type(Add-Type failed to create a type that implements IWebProxy #2764). By defaultAdd-Typewill reference all those reference assemblies when compiling C# code. If-ReferenceAssemblyis specified, then we search reference assemblies first, then the framework runtime assemblies, and lastly the loaded assemblies (possibly a third-party one that was already loaded).dotnet publishgenerates executable on Unix platforms, but doesn't set "x" permission and thus it cannot execute. Currently, the "x" permission is set in the build script,dotnet/cliissue #6286 is tracking this.SecureString.netcoreapp2.0becausedotnet-cli2.0.0-preview only works on osx.10.12.System.ValueTupleto work around a ambiguous type identity issue in coreclr. The issue is tracked bydotnet/corefx#17797. When moving to newer version ofnetcoreapp2.0, we need to verify if this dependency is still needed.