Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
858 views
in Technique[技术] by (71.8m points)

asp.net core - Cannot change Target Runtime when publishing to Azure from VS

I have a ASP.Core RC2 project (.NET 4.5.1 framework is used) that should be deployed on Azure as x86 Web-Site.

On Publish Setting tab in VS there are the following values:

  • Target Framework: .NET Framework 4.5.1
  • Target Runtime: Inferred Runtime (win7-x64)

What I want to change is the value of "Target Runtime" to x86 platform, but this combobox is inactive (grey).

Current project.json:

{
"version": "1.0.0-*",

"dependencies": {
  "Microsoft.NETCore.Platforms": "1.0.1-*",
  "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
  "Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
  "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
  "Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-final",
  "Microsoft.AspNetCore.Diagnostics": "1.0.0-rc2-final"
},

"commands": {
  "web": "Microsoft.AspNet.Server.Kestrel"
},

"buildOptions": {
  "emitEntryPoint": true
},

"frameworks": {
  "net451": { }
},

"publishOptions": {
  "include": [
    "appsettings.json",
    "project.json",
    "web.config",
    "NlogWeb.config"
  ]
},
"tools": {
  "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
    "version": "1.0.0-*",
    "imports": "portable-net45+wp80+win8+wpa81+dnxcore50"
  }
},
"scripts": {
  "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
}
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

When you're developing self-contained applications, you have to add all required runtimes to the project.json file, so that nuget/dotnet restore can download the runtime files on restore.

Adding the win7-x86 runtime to the project.json should do the trick.

"runtimes": {
    "win7-x64": { }, 
    "win7-x86": { } 
}

When you target portable apps, you don't need the runtimes section but you have to install the runtime yourself on the target machine. See .NET Core App Types documentation for a more detailed description on how portability types work and are configured.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...