2

This question is about a depeciated feature. dotnet core projects from version 2.x and up no longer require a project.json file.

When I build my project locally using visual studio everything works fine. However when I build it in VSTS using the recommended process from microsoft https://www.visualstudio.com/en-us/docs/build/apps/aspnet/aspnetcore-to-azure I can't get it to work.

I'm finding that when I do

dotnet restore

I get this error message

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.Domain' for '.NETFramework,Version=v4.6.1'.
    Unable to resolve 'Wedding.Persistence' for '.NETFramework,Version=v4.6.1'.

I have 5 projects within my solution and I think the dotnet restore is trying to get unbuilt projects.

My project.json contains this:

"frameworks": {
  "net461": {
    "dependencies": {
      "Wedding.Application": {
        "target": "project"
      },
      "Wedding.Common": {
        "target": "project"
      },
      "Wedding.Domain": {
          "target": "project"
      },
      "Wedding.Persistence": {
          "target": "project"
      }
    }
  }
},
chris31389
  • 8,414
  • 7
  • 55
  • 66

1 Answers1

3

Based on your description, it seems there are 4 dependencies missing when push the code to VSTS. I would suggest you check all files in VSTS. For publish and deploy ASP.Net core application to Azure via Visual studio, I would suggest you read this article. Read this article for more information about use VSTS to deploy.

[Update based on my comment]

Based on my experience, if you develop a .NET core application, It is better to choose .NET core class library. you can put common code in .NET Core projects in the same solution for future cross-platform re-use.

Jambor - MSFT
  • 3,175
  • 1
  • 13
  • 16
  • These 4 dependancies are projects included within my solution. – chris31389 Sep 19 '16 at 05:59
  • I know. These 4 dependencies are existing in VSTS? I attempt to create five projects on my local. everything works fine. Please try to push your solution to VSTS again to see whether it helps. – Jambor - MSFT Sep 19 '16 at 06:07
  • I've got all csproj + related files committed to source control. These 4 libraries are .NET 4.6.1 Class Libraries, but my WebApplication project is Core .NET 4.6.1. Could that be the problem? – chris31389 Sep 19 '16 at 06:16
  • 2
    Please try to use .NET core Class library instead of .NET library. And make sure the "frameworks" in .NET core project and .NET core library use the same "net461". – Jambor - MSFT Sep 19 '16 at 06:23
  • Running it locally is fine though? I dont understand why I would have to copy all my code to a core class library just so it deploys when it somehow runs in my local environment? – chris31389 Sep 19 '16 at 07:01
  • I've swapped to use Core libraries only and the dotnet restore now works. Can you amend your answer to state this a bit clearer and I can mark it as accepted. Thanks – chris31389 Sep 19 '16 at 09:23
  • I am glad to hear that you issue has been fixed. I have updated my reply. Hope it could be your answer. – Jambor - MSFT Sep 19 '16 at 12:17