dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.98k stars 4.66k forks source link

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

Closed xatabhk closed 4 years ago

xatabhk commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

@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 commented 8 years ago

@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 commented 8 years ago

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 commented 8 years ago

@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 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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

HamedFathi commented 8 years ago

@mellinoe

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

mellinoe commented 8 years ago

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

kscott5 commented 8 years ago

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

weshaggard commented 7 years ago

@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 commented 7 years ago

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%" ] } }

AlexGhiondea commented 7 years ago

@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 commented 7 years ago

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

radenkozec commented 7 years ago

@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 commented 7 years ago

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

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

radenkozec commented 7 years ago

@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 commented 7 years ago

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 commented 7 years ago

@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 commented 7 years ago

@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 commented 7 years ago

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

Pzixel commented 7 years ago

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

ericstj commented 7 years ago

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

ericstj commented 7 years ago

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

rubit0 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

@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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

this is infuriating.

StingyJack commented 7 years ago

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 commented 7 years ago

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

AlexGhiondea commented 7 years ago

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

aunoum commented 7 years ago

You can edit csproj files and add this line:

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

The result should look like this:

`

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

`

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 commented 7 years ago

@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 commented 7 years ago

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 commented 7 years ago

@aunoum - your suggestion solved it for me!

michaelbowman1024-zz commented 7 years ago

Thanks @rubit0 for the solution!

mattwoberts commented 7 years ago

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="System.Composition" Version="1.0.31" />

`

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

Any ideas?

AlexGhiondea commented 7 years ago

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

mattwoberts commented 7 years ago

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