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

Port System.ComponentModel.Composition (MEF1) to .NET Core #11857

Closed
dsplaisted opened this Issue Sep 19, 2016 · 37 comments

Comments

@dsplaisted
Member

dsplaisted commented Sep 19, 2016

With the additional APIs that will be available in .NET Standard 2.0, it may be possible to make System.ComponetModel.Composition (MEF1) available for .NET Core and .NET Standard 2.0. System.Composition (MEF2) is already available, but has a different feature set which can sometimes be an obstacle to porting code to .NET Core.

@dsplaisted dsplaisted changed the title from Port System.ComponentModel.Composition to .NET Core to Port System.ComponentModel.Composition (MEF1) to .NET Core Sep 19, 2016

@danmosemsft

This comment has been minimized.

Show comment
Hide comment
Member

danmosemsft commented Oct 5, 2016

@karelz

This comment has been minimized.

Show comment
Hide comment
@karelz

karelz Nov 16, 2016

Member

@weshaggard do you think it would be valuable, or should we just point devs to MEF2? (which already is part of .NET Core)

Member

karelz commented Nov 16, 2016

@weshaggard do you think it would be valuable, or should we just point devs to MEF2? (which already is part of .NET Core)

@weshaggard

This comment has been minimized.

Show comment
Hide comment
@weshaggard

weshaggard Nov 17, 2016

Member

I think it really depends on the customer. For folks that are using MEF1 in there applications they might be able to move to MEF2 but it might require subtle changes in their code and likely their extensions as well. We have converted some of our own usages of MEF1 to MEF2 in our tools but we owned the host and all the extensions, however for folks that don't own all the extensions it might be a challenge to move to .NET Core. I've not personally seen anyone get blocked and need MEF1 on core yet so I think we should probably wait until there folks that need it.

cc @Petermarcu

Member

weshaggard commented Nov 17, 2016

I think it really depends on the customer. For folks that are using MEF1 in there applications they might be able to move to MEF2 but it might require subtle changes in their code and likely their extensions as well. We have converted some of our own usages of MEF1 to MEF2 in our tools but we owned the host and all the extensions, however for folks that don't own all the extensions it might be a challenge to move to .NET Core. I've not personally seen anyone get blocked and need MEF1 on core yet so I think we should probably wait until there folks that need it.

cc @Petermarcu

@karelz

This comment has been minimized.

Show comment
Hide comment
@karelz

karelz Nov 18, 2016

Member

@danmosemsft @terrajobst should we close the issue?

Member

karelz commented Nov 18, 2016

@danmosemsft @terrajobst should we close the issue?

@terrajobst

This comment has been minimized.

Show comment
Hide comment
@terrajobst

terrajobst Nov 19, 2016

Member

We should leave it open and mark it up for grabs. This allows folks to vote for it so we can collect feedback.

Member

terrajobst commented Nov 19, 2016

We should leave it open and mark it up for grabs. This allows folks to vote for it so we can collect feedback.

@karelz

This comment has been minimized.

Show comment
Hide comment
@karelz

karelz Nov 19, 2016

Member

"up for grabs" issues have to be actionable for community members. The source code is not available in the open, which means internal source code access is needed.

Member

karelz commented Nov 19, 2016

"up for grabs" issues have to be actionable for community members. The source code is not available in the open, which means internal source code access is needed.

@karelz karelz removed the up-for-grabs label Nov 19, 2016

@terrajobst

This comment has been minimized.

Show comment
Hide comment
@terrajobst

terrajobst Nov 19, 2016

Member

MEF v1 was released as open-source. http://mef.codeplex.com. I've started the process to add it to https://github.com/microsoft/referencesource.

Member

terrajobst commented Nov 19, 2016

MEF v1 was released as open-source. http://mef.codeplex.com. I've started the process to add it to https://github.com/microsoft/referencesource.

@danmosemsft

This comment has been minimized.

Show comment
Hide comment
@danmosemsft

danmosemsft Sep 6, 2017

Member

If there are folks reading this who need MEFv1 on .NET Core, please thumbs up the top post and/or comment here.

Member

danmosemsft commented Sep 6, 2017

If there are folks reading this who need MEFv1 on .NET Core, please thumbs up the top post and/or comment here.

@debasisj

This comment has been minimized.

Show comment
Hide comment
@debasisj

debasisj Sep 21, 2017

my thumbs up to get it in .Net core 2.0

debasisj commented Sep 21, 2017

my thumbs up to get it in .Net core 2.0

@ludbul

This comment has been minimized.

Show comment
Hide comment
@ludbul

ludbul commented Sep 21, 2017

👍

@weshaggard

This comment has been minimized.

Show comment
Hide comment
@weshaggard

weshaggard Oct 26, 2017

Member

I don't know of any good documentation for MEF2. You can look under https://github.com/dotnet/corefx/tree/master/src/System.Composition/ at some samples/tests in there as I suspect that might be the best we have.

Member

weshaggard commented Oct 26, 2017

I don't know of any good documentation for MEF2. You can look under https://github.com/dotnet/corefx/tree/master/src/System.Composition/ at some samples/tests in there as I suspect that might be the best we have.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Nov 13, 2017

Is there anything left that was not ported in #24921 for MEF1?
Can we have a check list on remaining work?
Microsoft.Composition can be found under https://dotnet.myget.org/feed/dotnet-core/package/nuget/Microsoft.Composition which was last updated 5 months ago, where can i find nightly myget package for System.ComponentModel.Composition?
Has publishing all packages to myget feed stopped which this document promised: https://github.com/dotnet/corefx/blob/bd45cc980/Documentation/project-docs/dogfooding.md?
What's the new way to get nightlies, any announcements on the new world order?

KIS please 🙏
/end-of-confusions

ghost commented Nov 13, 2017

Is there anything left that was not ported in #24921 for MEF1?
Can we have a check list on remaining work?
Microsoft.Composition can be found under https://dotnet.myget.org/feed/dotnet-core/package/nuget/Microsoft.Composition which was last updated 5 months ago, where can i find nightly myget package for System.ComponentModel.Composition?
Has publishing all packages to myget feed stopped which this document promised: https://github.com/dotnet/corefx/blob/bd45cc980/Documentation/project-docs/dogfooding.md?
What's the new way to get nightlies, any announcements on the new world order?

KIS please 🙏
/end-of-confusions

@weshaggard

This comment has been minimized.

Show comment
Hide comment
@weshaggard

weshaggard Nov 13, 2017

Member

@kasper3 the port of the library has been completed but we haven't yet started producing a nuget package for it yet. @maryamariyan can give you more information about when that will be ready.

Member

weshaggard commented Nov 13, 2017

@kasper3 the port of the library has been completed but we haven't yet started producing a nuget package for it yet. @maryamariyan can give you more information about when that will be ready.

@maryamariyan

This comment has been minimized.

Show comment
Hide comment
@maryamariyan

maryamariyan Nov 14, 2017

Member

@kasper3 @weshaggard. We are porting the tests for System.ComponentModel.Composition and then we'll produce nuget packages. I am actively working on this.

Member

maryamariyan commented Nov 14, 2017

@kasper3 @weshaggard. We are porting the tests for System.ComponentModel.Composition and then we'll produce nuget packages. I am actively working on this.

@robooko

This comment has been minimized.

Show comment
Hide comment
@robooko

robooko Nov 17, 2017

@maryamariyan any idea when the nuget packages will be available?

robooko commented Nov 17, 2017

@maryamariyan any idea when the nuget packages will be available?

@safern

This comment has been minimized.

Show comment
Hide comment
@safern

safern Nov 17, 2017

Member

We published a pre-release package 2 days ago into nugget.

https://www.nuget.org/packages/System.Data.Odbc/4.5.0-preview1-25914-04

Also we published Microsoft.Windows.Compatibility which depends on this package + another set of packages that ported a bunch of APIs From Full Framework.

https://www.nuget.org/packages/Microsoft.Windows.Compatibility/2.0.0-preview1-25914-04

Member

safern commented Nov 17, 2017

We published a pre-release package 2 days ago into nugget.

https://www.nuget.org/packages/System.Data.Odbc/4.5.0-preview1-25914-04

Also we published Microsoft.Windows.Compatibility which depends on this package + another set of packages that ported a bunch of APIs From Full Framework.

https://www.nuget.org/packages/Microsoft.Windows.Compatibility/2.0.0-preview1-25914-04

@weshaggard

This comment has been minimized.

Show comment
Hide comment
@weshaggard

weshaggard Nov 17, 2017

Member

@safern he is asking about System.ComponentModel.Composition. I expect once @maryamariyan finishes the testing in the next few weeks we will create the package and start publishing it to our myget feed.

Member

weshaggard commented Nov 17, 2017

@safern he is asking about System.ComponentModel.Composition. I expect once @maryamariyan finishes the testing in the next few weeks we will create the package and start publishing it to our myget feed.

@safern

This comment has been minimized.

Show comment
Hide comment
@safern

safern Nov 17, 2017

Member

Hmmm, I misread and got confused as @maryamariyan also worked on System.Data.Odbc, sorry for the confusion.

Member

safern commented Nov 17, 2017

Hmmm, I misread and got confused as @maryamariyan also worked on System.Data.Odbc, sorry for the confusion.

@Petermarcu

This comment has been minimized.

Show comment
Hide comment
@Petermarcu

Petermarcu Nov 17, 2017

Member

Any reason we can't create the package even if complete testing isn't done?

Member

Petermarcu commented Nov 17, 2017

Any reason we can't create the package even if complete testing isn't done?

@safern

This comment has been minimized.

Show comment
Hide comment
@safern

safern Nov 17, 2017

Member

Any reason we can't create the package even if complete testing isn't done?

@maryamariyan will be working with me on adding the packaging so that we can have a preview package in myget early next week.

Member

safern commented Nov 17, 2017

Any reason we can't create the package even if complete testing isn't done?

@maryamariyan will be working with me on adding the packaging so that we can have a preview package in myget early next week.

maryamariyan added a commit that referenced this issue Nov 21, 2017

@safern

This comment has been minimized.

Show comment
Hide comment
@safern
Member

safern commented Nov 22, 2017

We have a preview version of this package now in myget:

https://dotnet.myget.org/feed/dotnet-core/package/nuget/System.ComponentModel.Composition

@steevcoco

This comment has been minimized.

Show comment
Hide comment
@steevcoco

steevcoco Dec 1, 2017

I've got a basic CompositionContainer feature set working with AssemblyCatalog and DirectoryCatalog in a NetStandard 2.0 project ... So that's great for me here!

steevcoco commented Dec 1, 2017

I've got a basic CompositionContainer feature set working with AssemblyCatalog and DirectoryCatalog in a NetStandard 2.0 project ... So that's great for me here!

@superriva

This comment has been minimized.

Show comment
Hide comment
@superriva

superriva Feb 27, 2018

@safern
Excuse me. Are you a developer of https://dotnet.myget.org/feed/dotnet-core/package/nuget/System.ComponentModel.Composition? I'm trying to make simple examples with the package but it fails.

superriva commented Feb 27, 2018

@safern
Excuse me. Are you a developer of https://dotnet.myget.org/feed/dotnet-core/package/nuget/System.ComponentModel.Composition? I'm trying to make simple examples with the package but it fails.

@dgxhubbard

This comment has been minimized.

Show comment
Hide comment
@dgxhubbard

dgxhubbard Mar 6, 2018

I am trying to load the package. I tried using the exact install cmd on site and got the following error.
What am I doing wrong?

Install-Package : Unable to find package System.Security.Permissions with version (>= 4.5.0-preview2-26306-04)

  • Found 6 version(s) in nuget.org [ Nearest version: 4.5.0-preview1-26216-02 ]
  • Found 0 version(s) in Microsoft Visual Studio Offline Packages
  • Found 0 version(s) in Local Packages
    At line:1 char:1
  • Install-Package System.ComponentModel.Composition -Version 4.5.0-prev ...
  •   + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
      + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
    
    

Install-Package : Package restore failed. Rolling back package changes for 'GtWebApi'.
At line:1 char:1

  • Install-Package System.ComponentModel.Composition -Version 4.5.0-prev ...
  •   + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
      + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
    
    
    

dgxhubbard commented Mar 6, 2018

I am trying to load the package. I tried using the exact install cmd on site and got the following error.
What am I doing wrong?

Install-Package : Unable to find package System.Security.Permissions with version (>= 4.5.0-preview2-26306-04)

  • Found 6 version(s) in nuget.org [ Nearest version: 4.5.0-preview1-26216-02 ]
  • Found 0 version(s) in Microsoft Visual Studio Offline Packages
  • Found 0 version(s) in Local Packages
    At line:1 char:1
  • Install-Package System.ComponentModel.Composition -Version 4.5.0-prev ...
  •   + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
      + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
    
    

Install-Package : Package restore failed. Rolling back package changes for 'GtWebApi'.
At line:1 char:1

  • Install-Package System.ComponentModel.Composition -Version 4.5.0-prev ...
  •   + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
      + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
    
    
    
@weshaggard

This comment has been minimized.

Show comment
Hide comment
@weshaggard

weshaggard Mar 7, 2018

Member

@dgxhubbard try installing again, that package set took a while to upload and index so you might have been trying to restore it before it was fully indexed. I see the package is present now though (https://dotnet.myget.org/feed/dotnet-core/package/nuget/System.Security.Permissions/4.5.0-preview2-26306-04).

Member

weshaggard commented Mar 7, 2018

@dgxhubbard try installing again, that package set took a while to upload and index so you might have been trying to restore it before it was fully indexed. I see the package is present now though (https://dotnet.myget.org/feed/dotnet-core/package/nuget/System.Security.Permissions/4.5.0-preview2-26306-04).

@dgxhubbard

This comment has been minimized.

Show comment
Hide comment
@dgxhubbard

dgxhubbard Mar 7, 2018

will do thanks

dgxhubbard commented Mar 7, 2018

will do thanks

@dgxhubbard

This comment has been minimized.

Show comment
Hide comment
@dgxhubbard

dgxhubbard Mar 7, 2018

Sorry I got the same result. Below is the command and response.

PM> Install-Package System.ComponentModel.Composition -Version 4.5.0-preview2-26306-04 -Source https://dotnet.myget.org/F/dotnet-core/api/v3/index.json
Restoring packages for C:\Repository\GtNext\Source\Web\GtWebApi\GtWebApi.csproj...
GET https://api.nuget.org/v3-flatcontainer/system.security.permissions/index.json
OK https://api.nuget.org/v3-flatcontainer/system.security.permissions/index.json 287ms
Install-Package : Unable to find package System.Security.Permissions with version (>= 4.5.0-preview2-26306-04)

  • Found 6 version(s) in nuget.org [ Nearest version: 4.5.0-preview1-26216-02 ]
  • Found 0 version(s) in Microsoft Visual Studio Offline Packages
  • Found 0 version(s) in Local Packages
    At line:1 char:1
  • Install-Package System.ComponentModel.Composition -Version 4.5.0-prev ...
  •   + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
      + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
    
    

Install-Package : Package restore failed. Rolling back package changes for 'GtWebApi'.
At line:1 char:1

  • Install-Package System.ComponentModel.Composition -Version 4.5.0-prev ...
  •   + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
      + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
    
    

Time Elapsed: 00:00:02.4345331

dgxhubbard commented Mar 7, 2018

Sorry I got the same result. Below is the command and response.

PM> Install-Package System.ComponentModel.Composition -Version 4.5.0-preview2-26306-04 -Source https://dotnet.myget.org/F/dotnet-core/api/v3/index.json
Restoring packages for C:\Repository\GtNext\Source\Web\GtWebApi\GtWebApi.csproj...
GET https://api.nuget.org/v3-flatcontainer/system.security.permissions/index.json
OK https://api.nuget.org/v3-flatcontainer/system.security.permissions/index.json 287ms
Install-Package : Unable to find package System.Security.Permissions with version (>= 4.5.0-preview2-26306-04)

  • Found 6 version(s) in nuget.org [ Nearest version: 4.5.0-preview1-26216-02 ]
  • Found 0 version(s) in Microsoft Visual Studio Offline Packages
  • Found 0 version(s) in Local Packages
    At line:1 char:1
  • Install-Package System.ComponentModel.Composition -Version 4.5.0-prev ...
  •   + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
      + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
    
    

Install-Package : Package restore failed. Rolling back package changes for 'GtWebApi'.
At line:1 char:1

  • Install-Package System.ComponentModel.Composition -Version 4.5.0-prev ...
  •   + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
      + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
    
    

Time Elapsed: 00:00:02.4345331

@weshaggard

This comment has been minimized.

Show comment
Hide comment
@weshaggard

weshaggard Mar 7, 2018

Member

It doesn't look like it is even trying to use "https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" as a source. Can you add that to your package sources in VS and try again?

Member

weshaggard commented Mar 7, 2018

It doesn't look like it is even trying to use "https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" as a source. Can you add that to your package sources in VS and try again?

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Mar 7, 2018

@dgxhubbard, in csproj, you can also add:

<PropertyGroup>
  <RestoreAdditionalProjectSources>https://dotnet.myget.org/F/dotnet-core/api/v3/index.json</RestoreAdditionalProjectSources>
  <!-- from https://github.com/NuGet/Home/wiki/%5BSpec%5D-NuGet-settings-in-MSBuild#project-properties -->
</PropertyGroup>

<ItemGroup>
  <PackageReference Include="System.ComponentModel.Composition" Version="4.5.0-*" />
</ItemGroup>

then dotnet restore, nuget restore or msbuild /restore (msbuild v15.3+, nuget 4.3+).

ghost commented Mar 7, 2018

@dgxhubbard, in csproj, you can also add:

<PropertyGroup>
  <RestoreAdditionalProjectSources>https://dotnet.myget.org/F/dotnet-core/api/v3/index.json</RestoreAdditionalProjectSources>
  <!-- from https://github.com/NuGet/Home/wiki/%5BSpec%5D-NuGet-settings-in-MSBuild#project-properties -->
</PropertyGroup>

<ItemGroup>
  <PackageReference Include="System.ComponentModel.Composition" Version="4.5.0-*" />
</ItemGroup>

then dotnet restore, nuget restore or msbuild /restore (msbuild v15.3+, nuget 4.3+).

@dgxhubbard

This comment has been minimized.

Show comment
Hide comment
@dgxhubbard

dgxhubbard commented Mar 8, 2018

Thanks adding "https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" as a source to vs worked.

@CZEMacLeod

This comment has been minimized.

Show comment
Hide comment
@CZEMacLeod

CZEMacLeod Apr 18, 2018

Hi All. Thanks for the snipped @kasper3 - Very useful for me.
What I am currently struggling with now is that System.ComponentModel.Composition.Registration does not seem to have a package available for it and is not included in the System.ComponentModel.Composition package.

The specific types I need are

  • System.ComponentModel.Composition.Registration.RegistrationBuilder
  • System.ComponentModel.Composition.Registration.PartBuilder
  • System.ComponentModel.Composition.Registration.PartBuilder<>

I am also struggling in the same bit of code with a reference to System.Reflection.Context.CustomReflectionContext which appears to be in System.Reflection.Context.dll for net461 and the System.Reflection.Context NuGet package does not include a framework reference for .NETFramework4.5 - as least in the release package 4.3.0. I can work around this one for now with conditional references in my project file, but it shouldn't be needed.

I don't know if I should raise new issues for these items, or whether here under a request for MEF1 in .NETCore / .NETStandard is the best place. (Note: My goal is to be able to migrate an application currently targeting net461 with over 100 projects / modules / plugins to either target multiple platforms or target netstandard2.0)
Some of the newer parts of the platform do use MEF2, which I believe has better support cross-platform but I don't have the resources at the moment to migrate the older MEF1 code as suggested earlier in the thread.

CZEMacLeod commented Apr 18, 2018

Hi All. Thanks for the snipped @kasper3 - Very useful for me.
What I am currently struggling with now is that System.ComponentModel.Composition.Registration does not seem to have a package available for it and is not included in the System.ComponentModel.Composition package.

The specific types I need are

  • System.ComponentModel.Composition.Registration.RegistrationBuilder
  • System.ComponentModel.Composition.Registration.PartBuilder
  • System.ComponentModel.Composition.Registration.PartBuilder<>

I am also struggling in the same bit of code with a reference to System.Reflection.Context.CustomReflectionContext which appears to be in System.Reflection.Context.dll for net461 and the System.Reflection.Context NuGet package does not include a framework reference for .NETFramework4.5 - as least in the release package 4.3.0. I can work around this one for now with conditional references in my project file, but it shouldn't be needed.

I don't know if I should raise new issues for these items, or whether here under a request for MEF1 in .NETCore / .NETStandard is the best place. (Note: My goal is to be able to migrate an application currently targeting net461 with over 100 projects / modules / plugins to either target multiple platforms or target netstandard2.0)
Some of the newer parts of the platform do use MEF2, which I believe has better support cross-platform but I don't have the resources at the moment to migrate the older MEF1 code as suggested earlier in the thread.

@weshaggard

This comment has been minimized.

Show comment
Hide comment
@weshaggard

weshaggard Apr 25, 2018

Member

@CZEMacLeod If you are interested in RegistrationBuilder APIs I suggest filing a new issue tracking it.

Member

weshaggard commented Apr 25, 2018

@CZEMacLeod If you are interested in RegistrationBuilder APIs I suggest filing a new issue tracking it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment