Here are threads in CLI and MVC repo https://github.com/aspnet/Mvc/issues/4663 and https://github.com/dotnet/cli/issues/3091 with no real answers. Thought it would be VS Tooling bug.
I have a asp.net project that reference a native dll via Nuget package. This native DLL is only build for x86. I've changed my project.json to set buildOptions
"platform": "x86"
But when I build this asp.net project via visual studio, it creates "bin\Debug\net46\win7-x64" as oppose to "win7-x86". If I run the resulting ".exe" file it would crash.
I've tried to use "dotnet build -r win7-x86" and it would create the right folder "bin\Debug\net46\win7-x86" and then I can run the ".exe" file.
Still cannot test the application in x86 mode.
Then I've uninstalled Microsoft .NET Code 1.0.0 RC2 - SDK Preview 1 (x64) which was installed via "VS 2015 Tooling Preview" and installed the "x86" one, and everything seems to be working.
I think it is not right. I should be have the option to install x64 and x86 and then via that buildOption I should be able to tell dotnet how to compile. Just like MSBuild and ASP.Net projects where I set the build options from Project Properties.
@BillHiebert this sounds similar to the build issues you were brought up a few weeks back. Is this a cli limitation?
@sayedihashimi seems like we found a fix here https://github.com/dotnet/cli/issues/3091
Update 1: false alarm, there is no fix, but this install x86 SDK (after x64 or just uninstall x64)
TFS: 224821
I've added this to our internal TFS, we will reply back here soon.
I can reproduce the same problem with ASP.NET Core 1.0 and Visual Studio 2015 Update 3. The easiest way to reproduce this is to open Visual Studio and create a new ASP.NET Core Web Application (.NET Framework) project and select the "Empty" project template. Run the project without making any changes and verify that the "Hello World!" web page is shown. Note that the folder /bin/Debug/net452/win7-x64 is created.
Now stop the web app, delete the Debug folder and then open project.json and add "platfrom": "x86" to the buildOptions section:
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true,
"platform": "x86"
},
Run the application again and this time a System.AggregateException is thrown from Microsoft.AspNetCore.Server.Kestrel.dll when host.Run() is called in Program.cs.
public class Program
{
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.Run(); // <= this throws an exception when platform is set to x86
}
}
Also note that the /bin/Debug/net452/win7-x64 is created instead of /bin/Debug/net452/win7-x86.
For completeness here is what my global.json file looks like:
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-preview2-003121"
}
}
Cross reference: https://github.com/aspnet/Home/issues/1624
Has anyone tested this in VS 2017? Can we expect a fix in VS 2017 RTM?
It should be fixed when VS2017 goes RTM /cc @nguerrera
Most helpful comment
It should be fixed when VS2017 goes RTM /cc @nguerrera