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

Dotnet restore fails: Microsoft.Composition 1.0.27 is not compatible with netcoreapp1.0 #17745

Closed
xatabhk opened this issue Jul 1, 2016 · 45 comments

Comments

@xatabhk
Copy link

xatabhk commented Jul 1, 2016

Errors in C:\downloads\web\projects\ZaxiTechCore\src\ZaxiTechCore\project.json
Package Microsoft.Composition 1.0.27 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Microsoft.Composition 1.0.27 supports: portable-net45+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile259)
One or more packages are incompatible with .NETCoreApp,Version=v1.0.

@mellinoe
Copy link
Contributor

mellinoe commented Jul 1, 2016

Hey @xatabhk,

Microsoft.Composition is our old nuget package which was published before we came up with the netstandard and netcoreapp concepts. So the nuget package doesn't explicitly support those frameworks. However, the assemblies in the package are all PCL assemblies, so you can reference them without trouble. To get NuGet to allow you to install the package into your project, add an "imports" statement, like this:

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [ "portable-net45+win8+wp8+wpa81" ]
    }
  },

Recently, we also published an updated version of the nuget package which has explicit support for netstandard (and therefore netcoreapp1.0). Right now it is only on our nightly dev feed as a beta version. That package is called "System.Composition" and has version v1.0.31-beta-24230-04. You can use it if you add this feed to your sources. I would recommend just adding the "imports" statement for now.

@xatabhk
Copy link
Author

xatabhk commented Jul 1, 2016

@mellinoe It is targeting "net452" instead of "netcoreapp1.0"; so there should no issue with the PCL assembly I think. Also only when "Microsoft.VisualStudio.Web.CodeGeneration.Tools" is referenced, I get this problem.

Here is my settings:

"frameworks": {
    "net452": {}
},

"tools": {
        "BundlerMinifier.Core": "2.1.258",
        "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview3-21486",
        "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview3-21486",
        "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview3-21486",
        "Microsoft.VisualStudio.Web.CodeGeneration.Tools": "1.0.0-preview3-21486"
},

    "dependencies": {
        "Microsoft.EntityFrameworkCore.Design": {
            "version": "1.0.0-*",
            "type": "build"
        },
        "Microsoft.EntityFrameworkCore.SqlServer.Design": {
            "version": "1.1.0-*",
            "type": "build"
        },
        "Microsoft.AspNetCore.Razor.Tools": {
            "version": "1.0.0-*",
            "type": "build"
        },
        "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
            "version": "1.0.0-*",
            "type": "build"
        },
        "Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
            "version": "1.0.0-*",
            "type": "build"
        },
        "Microsoft.EntityFrameworkCore.SqlServer": "1.1.0-*",
        "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.1.0-*",
        "Microsoft.AspNetCore.Diagnostics": "1.1.0-*",
        "Microsoft.AspNetCore.Mvc": "1.1.0-*",
        "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*",
 ...
}

So how to fix this when "net452" used.

@mellinoe
Copy link
Contributor

mellinoe commented Jul 1, 2016

@piotrpMSFT , @brthor This one seems like it may be a CLI bug to me. I'm not too familiar with how tool dependencies are handled, but @ericstj posited that we might be merging tool and project dependencies badly here, resulting in this error. Possible?

@brthor
Copy link
Contributor

brthor commented Jul 1, 2016

Each tool under the tools node has it's own dependency graph. It is independent from the project and from other tools. This is why putting the imports under the frameworks node did not work here, as that only affects the project's dependency graph.

Tools are also always restored for netcoreapp1.0 because they are expected to be portable. It looks like the library Microsoft.Composition 1.0.27 doesn't support netcoreapp1.0.

This can be resolved by directly adding imports to the tools node which requires it like so:

"BundlerMinifier.Core": { "version": "2.1.258", "imports": [ "portable-net45+win8+wp8+wpa81" ] }

(This is just an example, the imports would need to be added to whichever tool is bringing in Microsoft.Composition)

There is an example of fsc using imports here:
https://github.com/dotnet/cli/blob/rel/1.0.0/TestAssets/TestProjects/FSharpTestProjects/TestLibrary/project.json#L8

@xatabhk
Copy link
Author

xatabhk commented Jul 1, 2016

@brthor Yes. This workaround works. But I have another question: what is the different between the following two?
"tools"
{
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-*",
"imports": [ "portable-net45+win8+wp8+wpa81" ]
}

"dependencies": {
"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
"version": "1.0.0-*",
"type": "build"
},
}

Also updating package in IDE will get "tools"::"Microsoft.VisualStudio.Web.CodeGeneration.Tools" removed. Is "tools"::"Microsoft.VisualStudio.Web.CodeGeneration.Tools" not required for anything?

@ericstj
Copy link
Member

ericstj commented Jul 1, 2016

whichever tool is bringing in Microsoft.Composition

That's the bug @brthor, the tool doesn't bring it in. It's somehow leaking into the tool graph from the project's graph...

@brthor
Copy link
Contributor

brthor commented Jul 11, 2016

I'm confused here. Why does it seem that the tool dependency is leaking into the project graph?

Taking a look at the dependency graph for the tool, "Microsoft.VisualStudio.Web.CodeGeneration.Tools" it brings in

"Microsoft.CodeAnalysis.Workspaces.Common/1.3.0"

which brings in "Microsoft.Composition": "1.0.27"

Is this a bad dependency in "Microsoft.CodeAnalysis.Workspaces.Common/1.3.0" ?

@brthor
Copy link
Contributor

brthor commented Jul 11, 2016

To answer your question @xatabhk packages in the tools node are not linked up as dependencies of your project (so you couldn't do things like reference a dll inside a tool from your project).

Instead each tool is restored independently, and can provide commands available through the dotnet cli in the directory of that project.

For example, a tool package can have a file named dotnet-dostuff.dll which makes available the command dotnet dostuff in the directory of that project.

I'm not sure whether Microsoft.VisualStudio.Web.CodeGeneration.Tools is needed in your case because I am not familiar with that tool.

@PEsteves8
Copy link

The RC2 to 1.0 migration docs indicate that we can drop the imports statements in the tools. Everyone works except Microsoft.VisualStudio.Web.CodeGeneration.Tools.

Is that normal or is it supposed to work without the imports? The error is the same on indicated in this thread. The weird part is that in about 5 tools this is the only one with problems

@Flavien
Copy link

Flavien commented Aug 2, 2016

I'm also interested in the answer to the question raised by @PEsteves8.

@HamedFathi
Copy link

@mellinoe

When "System.Composition v1.0.31" released in official nuget ? I need it for my .NET Core project.

@mellinoe
Copy link
Contributor

@weshaggard , @ericstj Is it feasible to mark this single package as stable so that folks can use it?

@kscott5
Copy link

kscott5 commented Sep 20, 2016

Are you saying all Tools, ALWAYS, REQUIRE the use of Microsoft.Composition as a dependency for import?

@weshaggard
Copy link
Member

@mellinoe I don't know of any reason we cannot. We should probably do it as part of our 1.1 release however instead of doing it one-off, as we should not mark it stable in master.

@macakmujo
Copy link

I had problem with scaffolding in Visual Studio it looks like you need to include "Microsoft.VisualStudio.Web.CodeGeneration.Tools": "1.0.0-preview2-final"
under dependencies and tools, it works ok now :)

{
"userSecretsId": "aspnet-*_SHIT_",

"dependencies": {
"Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.1",
"Microsoft.EntityFrameworkCore.SqlServer.Design": "1.0.1",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
"BundlerMinifier.Core": "2.2.281",
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
},
"Microsoft.ApplicationInsights.AspNetCore": "1.0.2",
"Microsoft.EntityFrameworkCore": "1.0.1",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": "1.0.0-preview2-update1",
"Microsoft.EntityFrameworkCore.Tools.Core": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore.Tools.Cli": "1.0.0-preview1-final",
"Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore": "1.0.0-preview2-update1",
"Microsoft.VisualStudio.Web.CodeGeneration.Utils": "1.0.0-preview2-update1",
"Microsoft.VisualStudio.Web.CodeGeneration.Core": "1.0.0-preview2-update1",
"Microsoft.VisualStudio.Web.CodeGeneration": "1.0.0-preview2-update1",
"Microsoft.VisualStudio.Web.CodeGeneration.Templating": "1.0.0-preview2-update1",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": "1.0.0-preview2-final"
},

"tools": {
"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
"Microsoft.Extensions.SecretManager.Tools": "1.0.0-preview2-final",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview2-final",
"imports": [ "portable-net45+win8+wp8+wpa81" ]
}

},

"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
},

"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},

"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},

"publishOptions": {
"include": [
"wwwroot",
"Views",
"Areas/**/Views",
"appsettings.json",
"web.config"
]
},

"scripts": {
"prepublish": [ "bower install", "dotnet bundle" ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}

@karelz karelz assigned AlexGhiondea and unassigned mellinoe Nov 23, 2016
@AlexGhiondea
Copy link
Contributor

@macakmujo if I understand right, you have figure out a workaround for this? Can you confirm?

The other issue on the thread was around marking the package as stable. I will follow-up on it and will file a separate issue to address it if necessary.

@AlexGhiondea
Copy link
Contributor

The package 'System.Composition' is now marked as stable:
https://github.com/ericstj/corefx/blob/master/pkg/Microsoft.Private.PackageBaseline/packageIndex.json#L2880

@radenkozec
Copy link

radenkozec commented Nov 28, 2016

@AlexGhiondea Not sure how to workaround this.
I am now receiving this error:
The dependency Microsoft.Composition 1.0.27 does not support framework .NETCoreApp,Version=v1.1.
Tried all above none did not worked.
Microsoft.VisualStudio.Web.CodeGeneration.Tools and Microsoft.VisualStudio.Web.CodeGenerators.Mvc
are using this

@AlexGhiondea
Copy link
Contributor

@radenkozec I don't believe Microsoft.Composition supports netcoreapp1.1.

@weshaggard @twsouthwick any plans to make that package support 1.1?

@radenkozec
Copy link

@AlexGhiondea @weshaggard @twsouthwick If that is true ->
Microsoft.Composition does not support netcoreapp1.1 this means ->
Microsoft.VisualStudio.Web.CodeGeneration.Tools,
Microsoft.VisualStudio.Web.CodeGenerators.Mvc does not support netcoreapp1.1
which means that ASP.NET MVC 6 and ASP.NET 5 project does not support netcoreapp1.1

So you are saying that I cannot create ASP.NET MVC 6 netcoreapp1.1 right?

@mellinoe
Copy link
Contributor

Both packages "support" .NET Core 1.1, but the old package (Microsoft.Composition) requires that you use "imports" statements in your project file to install it, because of the way the package is authored. Ideally, downstream consumers will switch over to System.Composition because that is what we have named the package now. But it probably hasn't been at the top of the priority list because there aren't really any functional changes in the new package.

@radenkozec
Copy link

radenkozec commented Nov 29, 2016

@mellinoe I understand. I managed to import it using

"portable-net45+win8"

however it would be nice to not use these kind of workarounds for that.

@moozoo64
Copy link

@radenkozec
"brthor commented on 12 Jul" is saying that Microsoft.VisualStudio.* are adding addition commands to dotnet for the project. Most probably for design time while editing in Visual Studio.
I assume that if your not using Visual Studio then they aren't needed.
I'd also guess that if Visual Studio doesn't detect them it can still edit the project with less functionality.

To make the default template web site netcoreapp1.1 “pure” try this

Type
md aspnetcoreweb
cd aspnetcoreweb
dotnet new –t web

Then replace the project.json with the one in the attached project.zip
In Startup.cs comment out
app.UseBrowserLink();

dotnet restore
dotnet run

project.zip

PS Microsoft.VisualStudio.Web.CodeGeneration.Tools 1.1.0-preview4-final etc still appears dependent on Microsoft.Composition. Sigh.

@AlexGhiondea
Copy link
Contributor

I am going to close this now. Please re-open if this is still an issue.

@Pzixel
Copy link

Pzixel commented Dec 30, 2016

And nowadays how could this workadound be applied to csproj project? I don't have any project.json to add imports statement...

@ericstj
Copy link
Member

ericstj commented Dec 30, 2016

I believe the property that can be used in the csproj that case is PackageTargetFallback, @emgarten any docs on that?

@ericstj
Copy link
Member

ericstj commented Dec 30, 2016

Found them: https://docs.nuget.org/ndocs/schema/msbuild-targets#packagetargetfallback

@rubit0
Copy link

rubit0 commented Jan 1, 2017

I was having the same problem when creating a fresh Asp.Net Core project and referencing it from an xUnit project. My solution was to add the following node to the xUnit's .csproj file:

<PropertyGroup>
  <PackageTargetFallback>
    $(PackageTargetFallback);portable-net45+win8+wp8+wpa81;
  </PackageTargetFallback>
</PropertyGroup>

@irontoby
Copy link

I have a .csproj based ASP.NET Core 1.1 project in Visual Studio 2017 RC (using preview4 tools version) and am trying to figure out how to get these tools installed in my project, so that I can run dotnet aspnet-codegenerator for scaffolding.

All attempts using the above workarounds have failed, but maybe I'm not putting the PackageTargetFallback in the correct spot... could someone post a working example? Or is this not possible with the current 1.1 tooling?

@mellinoe
Copy link
Contributor

mellinoe commented Jan 31, 2017

All of the above are discussions on how to reference the old, obsolete package Microsoft.Composition. Going forward, you should just use the System.Composition package; it should be functionally identical but authored correctly for .NET Standard projects. Are you directly referencing Microsoft.Composition or is it pulled in transitively?

@irontoby
Copy link

@mellinoe it's being pulled in by Microsoft.VisualStudio.Web.CodeGeneration.Tools version 1.1.0-preview4-final.

It appears I need to add that package as a DotnetCliToolReference, in order to make the dotnet aspnet-codegenerator command available. But since that package probably doesn't yet understand the new csproj syntax anyway, I'm guessing I just need to wait on them to update it.

@aammfe
Copy link

aammfe commented Feb 8, 2017

Severity Code Description Project File Line Suppression State
Error Package Microsoft.Composition 1.0.27 is not compatible with netcoreapp1.1 (.NETCoreApp,Version=v1.1) / win. Package Microsoft.Composition 1.0.27 supports: portable-net45+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile259) 0

i have almost same issue , trying to add reference of core1.1 app to xunit project , using VS 2017 RC .

csproj
is being use means i could not use upper solutions

is there any solution ...?
or i have to go back to core 1.0 ?

@TimHess
Copy link

TimHess commented Feb 9, 2017

This info helped me get codegen working with netcoreapp1.1 on my machine
https://developercommunity.visualstudio.com/content/problem/10914/scaffolding-net-core-with-entity-framework.html

@veteze
Copy link

veteze commented Feb 27, 2017

this is infuriating.

@StingyJack
Copy link

When trying to add a WCF connected service in VS 2017, I get this in the output window.

"Package Microsoft.Composition 1.0.27 is not compatible with netcoreapp1.1"

and this in the WCF Service window

  Feeds used:
      E:\VS2017\COMMUNITY\COMMON7\IDE\EXTENSIONS\MICROSOFT\WCF CONNECTED SERVICE V0.5\svcutil
      https://api.nuget.org/v3/index.json
      C:\temp\nuget
      C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
An error occurred while bootstrapping svcutil. This usually happens when processing references.  You might be able to work around this problem by not providing reference parameters, and manually removing any types redefined in the generated proxy code.

Failed to generate service reference.

I tried adding MS.Composition 1.0.30 package to the aspnetcore proejct but still get the same error just with a different version. This all worked in VS 2015.

@RehanSaeed
Copy link

Has anyone got this working with csproj and netcoreapp1.1?

@AlexGhiondea
Copy link
Contributor

We realize this is frustrating and we are working on figuring out a way to fix this.

@aunoum
Copy link

aunoum commented Mar 23, 2017

You can edit csproj files and add this line:

<PackageTargetFallback>$(PackageTargetFallback);dotnet5.6;portable-net45+win8</PackageTargetFallback>

The result should look like this:

<PropertyGroup> <TargetFramework>netcoreapp1.1</TargetFramework> <PackageTargetFallback>$(PackageTargetFallback);dotnet5.6;portable-net45+win8</PackageTargetFallback> </PropertyGroup>

This is how VS converter does it when it upgrades project.json to csproj. If you need other targets, you can play around converting your project.json files to csproj files and see the output.

Hope this helps!

@StingyJack
Copy link

@aunoum - This was never a project.json so I cant try to convert, but I only need this for the scaffolding and it seems easy enough.

@StingyJack
Copy link

Thanks, I took all my hacks out and added the PackageTargetFallback and it didn't fail the New Scaffolding Item wizard, but it doesnt look like it puts things in the right places (controller was at the root of the project).

Maybe its supposed to do that normally? (I really don't know because the few times I could use Asp.net mvc over the last 5+ years have all pretty much been abandoned at about this point)

@tiagosomda
Copy link

tiagosomda commented Mar 24, 2017

@aunoum - your suggestion solved it for me!

hikalkan referenced this issue in aspnetboilerplate/aspnet-core-template Apr 26, 2017
@michaelbowman1024-zz
Copy link

Thanks @rubit0 for the solution!

@mattwoberts
Copy link

I have this issue too - I've got a .netcoreapp1.1 web project. When I add a new xunit test project, and then add a reference to my web project, I get:

Severity Code Description Project File Line Suppression State Error Package Microsoft.Composition 1.0.27 is not compatible with netcoreapp1.1 (.NETCoreApp,Version=v1.1). Package Microsoft.Composition 1.0.27 supports: portable-net45+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile259)

if I remove the reference to the web project, all works.

I've tried:

  1. Adding a PackageTargetFallback to both the web/test project
  2. Adding this to both the web/test project:
    <PackageReference Include="Microsoft.Composition" Version="1.0.27" ExcludeAssets="All" /> <PackageReference Include="System.Composition" Version="1.0.31" />

Both projects target netcoreapp1.1. and are csproj based.

Any ideas?

@AlexGhiondea
Copy link
Contributor

@mattwoberts could you try updating / adding a reference to Microsoft.Composition version 1.0.0.31?

@mattwoberts
Copy link

@AlexGhiondea Nice one, that seems to have solved it for me :)

@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 2.0.0 milestone Jan 31, 2020
Kavignon pushed a commit to hypertherm/DotNet.SystemCollections.Analyzers that referenced this issue Sep 21, 2020
When compiling the Test project on Azure DevOps, an old issue .NET Core arises with the dependency called Microsoft.Composition 1.0.27.

I followed this thread (dotnet/runtime#17745) and applied this fix(dotnet/runtime#17745 (comment))
@dotnet dotnet locked as resolved and limited conversation to collaborators Dec 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests