Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 :

{
  "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 ). However, win7-x64 runtime is used instead. I can see a win7-x64 output directory and the prompt title launched indicates it too.

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 ?

like image 967
DarkUrse Avatar asked Sep 14 '16 21:09

DarkUrse


2 Answers

There are 2 options:

  1. (global) Uninstall the 64 bit .net SDK and install the 32 bit one. Restart VS afterwards.
  2. (local) Put a new .net SDK in a different folder and add from a console that path to your PATH. Then start VS from there. It will pick the first dotnet it finds on the PATH.
like image 144
Victor Hurdugaci Avatar answered Oct 06 '22 05:10

Victor Hurdugaci


Victor Hurdugaci's answer should be upvoted, this here just provides some more information in case you need it.

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

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

This will hopefully get fixed after they switch from project.json to .csproj (why they change it here: Changes to Project.json).

At the moment when you have installed both versions like this (.NET Framework Downloads):

enter image description here

You need to set the order in the path environment variable:

enter image description here

So that the one you want to use appears first and then (re-)start Visual Studio.

To check which dotnet is currently "active" run: dotnet --info in the console.

like image 22
A.J.Bauer Avatar answered Oct 06 '22 05:10

A.J.Bauer