问题
I've got a solution that builds locally and I've created a new build and added one step to it
dotnet restore
I'm getting this error message:
... OTHER SUCCESSFUL INSTALLATIONS ...
log : Installing Microsoft.Extensions.FileProviders.Abstractions 1.0.0.
log : Installing Microsoft.Extensions.Configuration.Abstractions 1.0.0.
log : Installing Microsoft.Extensions.DependencyInjection.Abstractions 1.0.0.
log : Writing lock file to disk. Path: C:\a\1\s\Wedding.WebApp\project.lock.json
log : C:\a\1\s\Wedding.WebApp\project.json
log : Restore failed in 13722ms.
Errors in C:\a\1\s\Wedding.WebApp\project.json
Unable to resolve 'Wedding.Application' for '.NETFramework,Version=v4.6.1'.
Unable to resolve 'Wedding.Common' for '.NETFramework,Version=v4.6.1'.
Unable to resolve 'Wedding.WebApp.Setup' for '.NETFramework,Version=v4.6.1'.
Its refering to the three other projects that my main web project references.
This is my project.json
{
"dependencies": {
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0"
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"net461": {
"dependencies": {
"Wedding.Application": {
"target": "project"
},
"Wedding.Common": {
"target": "project"
},
"Wedding.WebApp.Setup": {
"target": "project"
}
}
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"publishOptions": {
"include": [
"wwwroot",
"web.config"
]
},
"scripts": {
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
Does anyone know why this might be erroring?
回答1:
Your dependencies
and frameworks
block don't look correct to me: I would expect the libraries you depend on to be declared within the dependencies
block, not the frameworks
block. It would more typically resemble this, for one project referencing another:
{
"dependencies": {
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Wedding.Application": { "target": "project" },
"Wedding.Common": { "target": "project" },
"Wedding.WebApp.Setup": { "target": "project" }
},
"frameworks": {
"net461": {
"imports": []
}
},
...
}
回答2:
Based on this answer to the same question:
Replace the project with a .NET Core class library. It worked for me.
回答3:
i`ve got simular problem. Solve that by manually swap project order in solution file.
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Some.Lib", "..\Some\Path\SomeProject.csproj", "{B539B811-6E75-48E0-A679-9F7092CC0261}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Some.Web.App", "SomePath\WebApplication3.csproj", "{244C097B-B6FD-4995-AAE3-87AB1748EA38}"
EndProject
Lib was .NetStandard 1.1 and Web.App on .NetFramework 4.6 Core 1.0.
Default project order doesn`t worked for me. After swap all fine.
来源:https://stackoverflow.com/questions/39478912/unable-to-resolve-error-when-try-dotnet-restore-multi-project-solution