0

I am currently trying to publish a web application out of VS2015. The solution is building, but when I want to publish I continuously get the error message: "Your project is not referencing the ".NETFrameworkVersion=v2.0" framework. Add a reference to ".NETFramewor, Version=v2.0" in the "frameworks" section of your project.json, and then re-run NuGet restore.

I already tried to change project.json in several ways that were suggested in StackOverflow ansers, but this was not working.

Can someone please help me out?

As a reference, I will add my project.json file and a screenshot of the problem.

Screenshot of the problem: https://i.stack.imgur.com/KjxDI.jpg

`{
  "userSecretsId": "aspnet-KrisnaldoApp-009a51e2-478c-4020-ac03-0a98477155a1",
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.1",
      "type": "platform"
    },
    "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.Mvc": "1.0.1",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Routing": "1.0.1",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.1",
    "Microsoft.EntityFrameworkCore.SqlServer.Design": {
      "version": "1.0.1",
      "type": "build"
    },
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "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",
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "System.Xml.XmlSerializer": "4.0.11",
    "System.Xml.XmlDocument": "4.0.1"
  },
  "tools": {
    "BundlerMinifier.Core": "2.0.238",
    "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
    "Microsoft.Extensions.SecretManager.Tools": "1.0.0-preview2-final",
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "imports": [
        "portable-net45+win8"
      ],
      "version": "1.0.0-preview2-final"
    }
  },
  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        "System.ServiceModel.Duplex": "4.0.1",
        "System.ServiceModel.Http": "4.1.0",
        "System.ServiceModel.NetTcp": "4.1.0",
        "System.ServiceModel.Security": "4.0.1"
      },
      "imports": [
        "dotnet2.0",
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  },
  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },
  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },
  "publishOptions": {
    "include": [
      "wwwroot",
      "**/*.cshtml",
      "appsettings.json",
      "web.config"
    ]
  },
  "scripts": {
    "prepublish": [
      "bower install",
      "dotnet bundle"
    ],
    "postpublish": [
      "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
    ]
  }
}`
JoachimAlly
  • 112
  • 7
  • Are you publishing to your local file system? If so, try changing the location, so you're publishing to a clean directory. – Mitch Stewart Jan 06 '18 at 18:59
  • I try to publish to my host account in smarterasp.net . I did it successfully in the past with my prevous PC (result: www.krisnaldos.be) – JoachimAlly Jan 06 '18 at 19:09
  • Try one of the proposed solutions outlined in this so post (https://stackoverflow.com/questions/36190601/your-project-is-not-referencing-the-netframework-version-v4-5-framework). Delete your bin, obj, and .vs directory. Then, rebuild & publish. – Mitch Stewart Jan 06 '18 at 19:14

1 Answers1

1

I usually resolve this by clicking on Restore Nuget Packages at the solution level. Also try to save your project.json to a different file, Delete the one in your solution and clean your project and add it back manually. Sometimes these files become locked.

Josh Adams
  • 2,113
  • 2
  • 13
  • 25
  • I deleted project.json and project.json.lock and copied it locally to clip board. Now I want to add it again, should I take something into account? And how should I clean the project? – JoachimAlly Jan 06 '18 at 19:09
  • right click on your solution >> Clean Solution, same can be done for individual projects in the solution – Josh Adams Jan 06 '18 at 19:15
  • Yes, this did solve the problem, thank you very much. :) – JoachimAlly Feb 17 '18 at 16:58