[英]Start an asp.net core project as x86 under visual studio 2015
I have a vs2015 solution containing an asp.net core project and have configured its project.json as follow : 我有一个包含asp.net核心项目的vs2015解决方案,并将其project.json配置如下:
{
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true,
"platform": "x86"
},
"runtimes": {
"win10-x86": {}
},
"frameworks": {
"net461": {}
},
"commands": {
"web": "Microsoft.AspNet.Hosting --ASPNET_ENV production --server Microsoft.AspNet.Server.Kestrel --server.urls http://+:12345",
}
[...]
}
I am expecting the application to build and run with the platform specified in project.json ( FYI, I am running the app via vs2015 debugger on a win10/x64 box ) . 我期待应用程序使用project.json中指定的平台构建和运行(仅供参考,我在win10 / x64框上通过vs2015调试器运行应用程序) 。 However, win7-x64 runtime is used instead.
但是,使用win7-x64运行时代替。 I can see a win7-x64 output directory and the prompt title launched indicates it too.
我可以看到一个win7-x64输出目录,启动的提示标题也表明它。
If I build and run directly via command line specifying the runtime, it works. 如果我通过指定运行时的命令行直接构建和运行,它就可以工作。
So my question is, what else do I need to configure to start the asp.net core app in x86 from vs2015 ? 所以我的问题是,我还需要配置什么来从vs2015启动x86中的asp.net核心应用程序?
There are 2 options: 有两种选择:
Victor Hurdugaci's answer should be upvoted, this here just provides some more information in case you need it. Victor Hurdugaci的答案应该被赞成,这里只是提供了一些更多的信息,以备你需要时使用。
There seems to be a tooling issue at the moment when you have installed both the x86 and x64 .NET Core versions (More on this here: 32 bit not in good state and workarounds and the links). 当您安装了x86和x64 .NET Core版本时,似乎存在一个工具问题(此处有更多相关信息: 32位处于良好状态和解决方法以及链接)。
Setting "buildOptions" to "platform": "x86" and "runtimes": to "win7-x86" in project.json is not working (the x64 directory can still get created during built depending on the PATH environment variable). 将“buildOptions”设置为“platform”:“x86”和“runtimes”:到project.json中的“win7-x86”不起作用(x64目录仍然可以在构建期间根据PATH环境变量创建)。
This will hopefully get fixed after they switch from project.json to .csproj (why they change it here: Changes to Project.json ). 希望它们在从project.json切换到.csproj之后得到修复(为什么他们在这里更改它: 对Project.json的更改 )。
At the moment when you have installed both versions like this ( .NET Framework Downloads ): 在您安装这两个版本的时刻( .NET Framework下载 ):
You need to set the order in the path environment variable: 您需要在路径环境变量中设置顺序:
So that the one you want to use appears first and then (re-)start Visual Studio. 这样你想要使用的那个首先出现然后(重新)启动 Visual Studio。
To check which dotnet is currently "active" run: dotnet --info in the console. 要检查哪个dotnet当前处于“活动状态”,请运行:dotnet --info在控制台中。
This is what worked for me : 这对我有用:
An hour ago, visual studio 2015 team released a new update labeled " Microsoft Visual Studio 2015 Update 3 (KB3165756) " 一小时前,visual studio 2015团队发布了一个标有“ Microsoft Visual Studio 2015 Update 3(KB3165756) ”的新更新
After installation, everything works as expected. 安装后,一切都按预期工作。
A big thanks to MS and .net core / vs2015 teams for this extremely timely release :) 非常感谢MS和.net核心/ vs2015团队为这个非常及时的发布:)
Addendum: 附录:
Installing the update isn't enough ( although I suspect it is part of the fix ). 安装更新是不够的(虽然我怀疑它是修复的一部分)。 The additional steps to make this work you need to follow @VictorHurdugaci directives:
要使这项工作的其他步骤,您需要遵循@VictorHurdugaci指令:
Ensure you have installed the x86 version of the .net SDK 确保已安装.86 SDK的x86版本
And ensure PATH order of "C:\\Program Files (x86)\\dotnet\\" before "C:\\Program Files\\dotnet\\" the runtime which is not guaranteed when you install the new package ( I wanted to keep both x86 and x64 runtimes ) 并确保PATH为了“C:\\ Program Files文件(x86)的\\ DOTNET \\”之前的“C:\\ Program Files文件\\ DOTNET \\”当你安装新的包,它不能保证运行时(我想保持于x86和x64运行时)
Thanks VictorHurdugaci, at the end of the day you were absolutely correct. 感谢VictorHurdugaci,在一天结束时你绝对正确。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.