17

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?

Maximilian Riegler
  • 22,720
  • 4
  • 62
  • 71
chris31389
  • 8,414
  • 7
  • 55
  • 66
  • As a major work around I found I needed to create a new WebApp and a new project. I then ported my code bit by bit to the new project publishing it to the new WebApp. After each time checking that it published ok. After porting everything across I have no idea what caused this but I'm now able to publish by right clicking the project. – chris31389 Oct 31 '16 at 07:26
  • I've found the same thing. An annoying workaround, but at least it got rid of the error. – Alyce Nov 01 '16 at 01:40
  • Have you tried to move the dependencies under `net461` to the place under the `dependencies` node? – Deilan Nov 16 '16 at 13:58
  • I haven't no, did this work for you? I've rebuilt my project from the ground up and im now able to publish the project which was my original aim. I was trying to do it before within TFS – chris31389 Nov 19 '16 at 09:01
  • 1
    I got same issue. For me the only solution without changing my sln structure was replace restore dotnet core and visual studio build steps by NuGet Restore and MSBuild build steps. Also, you must check the follow things: 1) Make sure you select 3.4.4 or later Nuget Version in Nuget Restore step advanced configuration. 2) In Nuget Restore configuration you must select your solution in "Path to Solution or packages.config" field. 3) Make sure Restore Nuget Packages is unchecked in MSBuild step advanced configuration. – Luty Nov 22 '16 at 15:26
  • Do you have a global.json file? Dotnet needs to know where the projects are. Are the other projects netstandard or net461? – Thomas Feb 12 '17 at 08:26
  • Hi Thomas, the other projects were net461 – chris31389 Feb 13 '17 at 16:32

3 Answers3

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": []
    }
  },

  ...
}
Ken Mason
  • 712
  • 2
  • 7
  • 16
0

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.

Surgerer
  • 157
  • 9
-1

Based on this answer to the same question:

Replace the project with a .NET Core class library. It worked for me.

Community
  • 1
  • 1
Kristoffer Jälén
  • 4,112
  • 3
  • 30
  • 54