简体   繁体   English

在visual studio 2015下以x86开始一个asp.net核心项目

[英]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: 有两种选择:

  1. (global) Uninstall the 64 bit .net SDK and install the 32 bit one. (全局)卸载64位.net SDK并安装32位。 Restart VS afterwards. 之后重启VS.
  2. (local) Put a new .net SDK in a different folder and add from a console that path to your PATH. (本地)将新的.net SDK放在不同的文件夹中,并从控制台添加到PATH的路径。 Then start VS from there. 然后从那里开始VS. It will pick the first dotnet it finds on the PATH. 它将选择它在PATH上找到的第一个dotnet。

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指令:

  1. Ensure you have installed the x86 version of the .net SDK 确保已安装.86 SDK的x86版本

  2. 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.

相关问题 Visual Studio-无法启动ASP.NET Core项目 - Visual Studio - Cannot start ASP.NET Core project 如何在Visual Studio 2015中创建ASP.NET MVC 4项目 - How to Create an ASP.NET MVC 4 project in visual studio 2015 将x86 asp.net项目转换为x64时出错 - Error Converting x86 asp.net project to x64 在x86模式下构建MVC6 / ASP.Net 5项目 - Build MVC6 / ASP.Net 5 project in x86 mode 在Visual Studio 2015更新3中缺少“ASP.NET核心Web应用程序(.NET核心)”模板? - missing “ASP.NET Core Web Application (.NET Core)” template in Visual studio 2015 update 3? VS 2017 .NET 4.6.2新的ASP.NET核心Web应用程序(.NET Framework)默认为x86平台 - VS 2017 .NET 4.6.2 new ASP.NET Core Web Application (.NET Framework) defaults to x86 platform 在Asp.Net core 1.0(Visual Studio 2015)中的标签帮助器中需要帮助 - Need help in tag helper in Asp.Net core 1.0 (Visual Studio 2015) ASP.NET核心 - 在Visual Studio 2015中通​​过Docker进行调试时出现的问题 - ASP.NET Core - Issues while Debugging through Docker in Visual Studio 2015 SonarLint Visual Studio 2015插件不支持asp.net核心? - SonarLint Visual Studio 2015 plugin does not support asp.net core? 如何在 Visual Studio 2015 上的 ASP.NET 核心中创建 T4 文本模板(.tt) - How to create T4 text templates(.tt) in ASP.NET core on Visual Studio 2015
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM