To See how to create a .Net core app, Click here …
First Open the project and you can see there is a JSON file called “project.json”
Then click it and you will see the JSON content in that file.
The default JSON content like below.
{ "dependencies": { "Microsoft.NETCore.App": { "version": "1.0.1", "type": "platform" }, "Microsoft.AspNetCore.Diagnostics": "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.Extensions.Configuration.EnvironmentVariables": "1.0.0", "Microsoft.Extensions.Configuration.Json": "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" }, "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" }, "frameworks": { "netcoreapp1.0": { "imports": [ "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%" ] } }
When we collapse the JSON content, we can see what are the main properties of the file..
So according to above image, there is no property to declare Target Runtimes.
So We have to add them manually according to our requirement. I’m using windows based machines, so I’ll add windows operating systems as target runtimes.
"runtimes": { "win10-x64": {}, "win81-x64": {}, "win8-x64": {}, "win7-x64": {}, "win7-x86": {} }
When you add this code, you could see the NuGet package references are restoring automatically in the right hand side .
After It has completed, you are ready to publish the app.
Then Right click on the project and click “Publish”.
You will see the Publish window. And Go to the settings menu and you will see those runtimes has added to the target runtimes drop down list.
Important.
If you want to delete old published files when you are publishing a new version, Check the
“Delete all existing files prior to publish” check box..
Thanks !
Pingback: Fix Error : “Could not find a part of the path” While Publishing ASP.NET Core MVC Application To the Target Platform of Windows 7 x64/x86 | Codez with Buddhima