dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.69k stars 1.06k forks source link

Mismatch between processor architecture. #7881

Open ravipal opened 7 years ago

ravipal commented 7 years ago

Steps to reproduce

  1. In VS 2015 create a .net web project targeting full framework.
  2. Add a Nuget package reference to "Microsoft.ServiceFabric.Services" which targets only AMD64. or any other package that targets only AMD64.
  3. Build -> build will be fine.
  4. Open this project in another machine with VS 2017 and this will migrate the project.
  5. Build

Expected behavior

Build should succeed

Actual behavior

Build shows several warnings

1>------ Build started: Project: WebApplication1, Configuration: Debug Any CPU ------ 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1964,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "x86" and the processor architecture of the reference "C:\Users\ravipal.nuget\packages\microsoft.servicefabric.data\2.4.164\lib\net45\Microsoft.ServiceFabric.Data.dll", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1964,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "x86" and the processor architecture of the reference "C:\Users\ravipal.nuget\packages\microsoft.servicefabric.data\2.4.164\lib\net45\Microsoft.ServiceFabric.Data.Interfaces.dll", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1964,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "x86" and the processor architecture of the reference "C:\Users\ravipal.nuget\packages\microsoft.servicefabric\5.4.164\lib\net45\Microsoft.ServiceFabric.Internal.dll", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1964,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "x86" and the processor architecture of the reference "C:\Users\ravipal.nuget\packages\microsoft.servicefabric\5.4.164\lib\net45\Microsoft.ServiceFabric.Internal.Strings.dll", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1964,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "x86" and the processor architecture of the reference "C:\Users\ravipal.nuget\packages\microsoft.servicefabric.services\2.4.164\lib\net45\Microsoft.ServiceFabric.Services.dll", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1964,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "x86" and the processor architecture of the reference "C:\Users\ravipal.nuget\packages\microsoft.servicefabric.services\2.4.164\lib\net45\ServiceFabricServiceModel.dll", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1964,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "x86" and the processor architecture of the reference "C:\Users\ravipal.nuget\packages\microsoft.servicefabric\5.4.164\lib\net45\System.Fabric.dll", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1964,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "x86" and the processor architecture of the reference "C:\Users\ravipal.nuget\packages\microsoft.servicefabric\5.4.164\lib\net45\System.Fabric.Strings.dll", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. 1>WebApplication1 -> C:\Users\ravipal\Documents\Visual Studio 2017\Projects\WebApplication1\src\WebApplication1\bin\Debug\net452\WebApplication1.exe 1>Done building project "WebApplication1.csproj". ========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========

Environment data

dotnet --info output: .NET Command Line Tools (1.0.0-rc4-004847)

Product Information: Version: 1.0.0-rc4-004847 Commit SHA-1 hash: b7692237d1

Runtime Environment: OS Name: Windows OS Version: 10.0.14393 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\1.0.0-rc4-004847

fleed commented 7 years ago

I think that I've solved the issue. I've changed <RuntimeIdentifiers>win7-x64</RuntimeIdentifiers> to <RuntimeIdentifier>win7-x64</RuntimeIdentifier> and now warnings are gone and also don't have the runtime exception.

livarcocc commented 7 years ago

We have fixed this in migrate for version 1.0.0 of the CLI, where we don't add the runtime identifiers anymore.

ravipal commented 7 years ago

My project didn't have runtimeidentifier. Please reopen the issue.

livarcocc commented 7 years ago

Can you share your original project.json?

I am not aware of a AMD64 runtime. AFAIK, these are the RIDs supported by .NET Core: win7-x64;win7-x86;osx.10.10-x64;osx.10.11-x64;ubuntu.14.04-x64;ubuntu.16.04-x64;ubuntu.16.10-x64;centos.7-x64;rhel.7.2-x64;debian.8-x64;fedora.23-x64;fedora.24-x64;opensuse.13.2-x64;opensuse.42.1-x64.

ravipal commented 7 years ago

This is the content of project.json

{ "dependencies": { "Microsoft.ApplicationInsights.AspNetCore": "1.0.0", "Microsoft.AspNetCore.Diagnostics": "1.0.0", "Microsoft.AspNetCore.Mvc": "1.0.0", "Microsoft.AspNetCore.Razor.Tools": { "version": "1.0.0-preview2-final", "type": "build" }, "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0", "Microsoft.AspNetCore.StaticFiles": "1.0.0", "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0", "Microsoft.Extensions.Configuration.Json": "1.0.0", "Microsoft.Extensions.Logging": "1.0.0", "Microsoft.Extensions.Logging.Console": "1.0.0", "Microsoft.Extensions.Logging.Debug": "1.0.0", "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0", "Microsoft.ServiceFabric.Services": "2.4.164", "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0" },

"tools": { "BundlerMinifier.Core": "2.0.238", "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final", "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final" },

"frameworks": { "net452": { } },

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

"publishOptions": { "include": [ "wwwroot", "Views", "Areas/**/Views", "appsettings.json", "web.config" ] },

"scripts": { "prepublish": [ "bower install", "dotnet bundle" ], "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] } }

ravipal commented 7 years ago

Sorry, accidentally closed.

livarcocc commented 7 years ago

@ravipal I just tried this out and it all worked out.

Here is my project.json:

{
  "userSecretsId": "aspnet-WebApplication-0799fe3e-6eaf-4c5f-b40e-7c6bfd5dfa9a",

  "dependencies": {
    "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0",
    "Microsoft.AspNetCore.Diagnostics": "1.1.0",
    "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.1.0",
    "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.1.0",
    "Microsoft.AspNetCore.Mvc": "1.1.0",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.1.0-preview4-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Routing": "1.1.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
    "Microsoft.AspNetCore.StaticFiles": "1.1.0",
    "Microsoft.EntityFrameworkCore.Sqlite": "1.1.0",
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.1.0-preview4-final",
      "type": "build"
    },
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
    "Microsoft.Extensions.Configuration.Json": "1.1.0",
    "Microsoft.Extensions.Configuration.UserSecrets": "1.1.0",
    "Microsoft.Extensions.Logging": "1.1.0",
    "Microsoft.Extensions.Logging.Console": "1.1.0",
    "Microsoft.Extensions.Logging.Debug": "1.1.0",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.1.0",
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "version": "1.1.0-preview4-final",
      "type": "build"
    },
    "Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
      "version": "1.1.0-preview4-final",
      "type": "build"
    },
    "Microsoft.ServiceFabric.Services": "2.4.164"
  },

  "tools": {
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.1.0-preview4-final",
      "imports": "portable-net45+win8+dnxcore50"
    },
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
      "version": "1.1.0-preview4-final",
      "imports": "portable-net45+win8+dnxcore50"
    },
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.1.0-preview4-final",
      "imports": [
        "portable-net45+win8+dnxcore50",
        "portable-net45+win8"
      ]
    },
    "Microsoft.Extensions.SecretManager.Tools": {
      "version": "1.1.0-preview4-final",
      "imports": "portable-net45+win8+dnxcore50"
    },
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "version": "1.1.0-preview4-final",
      "imports": [
        "portable-net45+win8+dnxcore50",
        "portable-net45+win8"
      ]
    }
  },

  "frameworks": {
    "net452": {}
  },

  "buildOptions": {
    "debugType": "portable",
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "**/*.cshtml",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  },

  "tooling": {
    "defaultNamespace": "WebApplication"
  }
}

And here is the migrated csproj:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net452</TargetFramework>
    <DebugType>portable</DebugType>
    <PreserveCompilationContext>true</PreserveCompilationContext>
    <AssemblyName>temp</AssemblyName>
    <OutputType>Exe</OutputType>
    <PackageId>temp</PackageId>
    <UserSecretsId>aspnet-WebApplication-0799fe3e-6eaf-4c5f-b40e-7c6bfd5dfa9a</UserSecretsId>
  </PropertyGroup>

  <ItemGroup>
    <None Update="wwwroot\**\*">
      <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
    </None>
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="1.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="1.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="1.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
    <PackageReference Include="Microsoft.AspNetCore.Routing" Version="1.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="1.1.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.0.0">
      <PrivateAssets>All</PrivateAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="1.1.1" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.1" />
    <PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="1.1.1" />
    <PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.1" />
    <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.1" />
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
    <PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.0" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="1.1.0">
      <PrivateAssets>All</PrivateAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.ServiceFabric.Services" Version="2.4.164" />
  </ItemGroup>

  <ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
    <Reference Include="System" />
    <Reference Include="Microsoft.CSharp" />
  </ItemGroup>

  <Target Name="PrepublishScript" BeforeTargets="PrepareForPublish">
    <Exec Command="npm install" />
    <Exec Command="bower install" />
    <Exec Command="gulp clean" />
    <Exec Command="gulp min" />
  </Target>

  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />
    <DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="1.0.0" />
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />
  </ItemGroup>

</Project>

In both cases dotnet restore/run succeeded and the page loaded with problems.

I also checked the package that you mentioned above and in nuget.org I can see that it targets net45 and not AMD64.

I wonder if by any chance you had a pointer to a private version of this package in the past that target AMD64 and now it is there in your nuget cache. If that's the case, I would suggest cleaning up that package from the cache and running restore/run again.

ravipal commented 7 years ago

I tried it again after clearing the local nuget cache. Still I ran into the same issue. I didn't run 'dotnet restore' instead opened the project in VS that migrated and then built.

Can you please try the steps I mentioned in the issue. Or skip the first 3 steps and use the project from \scratch2\scratch\ravipal\share\5967

ek68794998 commented 7 years ago

I'm able to reproduce this issue as well. I have tried with both x64 and Any CPU configurations in my solution.

My csproj:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net452</TargetFramework>
    <PreserveCompilationContext>true</PreserveCompilationContext>
    <AssemblyName>Foo</AssemblyName>
    <OutputType>Exe</OutputType>
    <PackageId>Foo</PackageId>
  </PropertyGroup>

  <ItemGroup>
    <None Include="App.config" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
    <PackageReference Include="Microsoft.AspNetCore.Routing" Version="1.1.1" />
    <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="1.1.1" />
    <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="1.0.2" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.0.2" />
    <PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.1" />
    <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.0.2" />
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.0.2" />
    <PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.0.2" />
    <PackageReference Include="Microsoft.ServiceFabric" Version="5.4.145" />
    <PackageReference Include="Microsoft.ServiceFabric.Data" Version="2.4.145" />
    <PackageReference Include="Microsoft.ServiceFabric.Services" Version="2.4.145" />
    <PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
  </ItemGroup>

  <ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
    <Reference Include="System.Web" />
    <Reference Include="System" />
    <Reference Include="Microsoft.CSharp" />
  </ItemGroup>

</Project>

Errors:

Warning CS8012  Referenced assembly 'Microsoft.ServiceFabric.Services, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' targets a different processor.    Foo CSC 1   Active
Warning CS8012  Referenced assembly 'System.Fabric, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' targets a different processor.   Foo CSC 1   Active
Warning MSB3270 There was a mismatch between the processor architecture of the project being built "x86" and the processor architecture of the reference "C:\...\.nuget\packages\microsoft.servicefabric.data\2.4.145\lib\net45\Microsoft.ServiceFabric.Data.dll", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. Foo Microsoft.Common.CurrentVersion.targets 1964    
Warning MSB3270 There was a mismatch between the processor architecture of the project being built "x86" and the processor architecture of the reference "C:\...\.nuget\packages\microsoft.servicefabric.data\2.4.145\lib\net45\Microsoft.ServiceFabric.Data.Interfaces.dll", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.  Foo Microsoft.Common.CurrentVersion.targets 1964    
Warning MSB3270 There was a mismatch between the processor architecture of the project being built "x86" and the processor architecture of the reference "C:\...\.nuget\packages\microsoft.servicefabric\5.4.145\lib\net45\Microsoft.ServiceFabric.Internal.dll", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.  Foo Microsoft.Common.CurrentVersion.targets 1964    
Warning MSB3270 There was a mismatch between the processor architecture of the project being built "x86" and the processor architecture of the reference "C:\...\.nuget\packages\microsoft.servicefabric\5.4.145\lib\net45\Microsoft.ServiceFabric.Internal.Strings.dll", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.  Foo Microsoft.Common.CurrentVersion.targets 1964    
Warning MSB3270 There was a mismatch between the processor architecture of the project being built "x86" and the processor architecture of the reference "C:\...\.nuget\packages\microsoft.servicefabric.services\2.4.145\lib\net45\Microsoft.ServiceFabric.Services.dll", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. Foo Microsoft.Common.CurrentVersion.targets 1964    
Warning MSB3270 There was a mismatch between the processor architecture of the project being built "x86" and the processor architecture of the reference "C:\...\.nuget\packages\microsoft.servicefabric.services\2.4.145\lib\net45\ServiceFabricServiceModel.dll", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.    Foo Microsoft.Common.CurrentVersion.targets 1964    
Warning MSB3270 There was a mismatch between the processor architecture of the project being built "x86" and the processor architecture of the reference "C:\...\.nuget\packages\microsoft.servicefabric\5.4.145\lib\net45\System.Fabric.dll", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. Foo Microsoft.Common.CurrentVersion.targets 1964    
Warning MSB3270 There was a mismatch between the processor architecture of the project being built "x86" and the processor architecture of the reference "C:\...\.nuget\packages\microsoft.servicefabric\5.4.145\lib\net45\System.Fabric.Strings.dll", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. Foo Microsoft.Common.CurrentVersion.targets 1964    
arisliang commented 7 years ago

any progress with this? I'm having the same issue while convert the target platform from AnyCPU to x64.

vikalyan commented 7 years ago

I am having this issue with VS 2017 and .NET Core 1.1. The projects were not migrated but started out as MSBuild project files.

ravipal commented 7 years ago

@livarcocc, Any update on this?

tbertenshaw commented 7 years ago

I'm having this issue with dotnetcore2.0 and vs2017 15.3.1

tbertenshaw commented 7 years ago

I tried a few times on different machines/installations of Vs2017 15.3.1 Professional. Both machines with latest Service fabric installed and the local dev clusters redeployed to latest version.

  1. new service fabric application
  2. choose a stateless aspnet core application
  3. choose webapi or MVC (aspnetcore 2)
  4. after solution is ready. right click the controllers folder and add new controller. The dialog pops up for scaffolding options, choose full dependencies option.
  5. build and hey presto you get the warning.

Debugging the application throws an exception on startup

sample code below https://github.com/tbertenshaw/SFBlueGreen

jxbolt commented 7 years ago

Possible related to your issue @tbertenshaw https://github.com/aspnet/Scaffolding/pull/605

lcalabrese commented 7 years ago

I'm having this issue in VS2017 with the new csproj format. Platform target is set to AnyCPU and I'm attempting to target frameworks net461 and netcoreapp2.0 .

Warning MSB3270 There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.visualstudio.web.codegeneration.design\2.0.0\lib\net461\dotnet-aspnet-codegenerator-design.exe", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.

The line referenced is C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets;1987

In project.json I believe we were able to work around this by adding an import in the tools section, but this is no longer supported in the new csproj format. Or, perhaps it was compiled for x86 and should have been MSIL or have multiple assemblies.

Edit: I just looked at pull request https://github.com/aspnet/Scaffolding/pull/605 and this should do the trick.

livarcocc commented 7 years ago

I don't think the original issue related here is the scaffolding problem mentioned above. @prafullbhosale can you take a look and comment?

Also, @ravipal is this still happening to you?

prafullbhosale commented 7 years ago

The original issue doesn't have the Microsoft.VisualStudio.Web.CodeGeneration.Design package reference. The aspnet/scaffolding/issues/601 should only happen if you have this package reference.

ravipal commented 7 years ago

@livarcocc Yes it still happens. Again, the repro steps are

  1. Open the project \\scratch2\scratch\ravipal\share\5967 in VS 2017 and let it migrate.
  2. Build.
am11 commented 7 years ago

I was getting MSB3270 warning when running package target on SFPROJ, the fabric service was upgraded to netcoreapp2.0 and the fix in CSPROJ was to set PlatformTarget properties:

-    <Platform>x64</Platform>
+    <PlatformTarget>x64</PlatformTarget>

if csproj already has RID RuntimeIdentifier(s) property set, the PlatformTarget is not required

If you are targeting full framework, don't have/want AnyCpu configs in SLN (only x64), don't want to set RID prop as well (FFD vs. SCD); then you might need to keep Platform property set as well.

Would be cool if SDK handles it for projects where Platform is set; as for most users, Platform (host) == PlatformTarget, and for exclusive scenarios, let user override PlatformTarget as today. Today SDK defaults to MSIL.

inetkid commented 6 years ago

Read here to run IIS Express in 64 bits. https://ppolyzos.com/2015/12/01/enable-x64-bit-version-of-iis-express/

livarcocc commented 6 years ago

@ravimeda I believe this happens because of inference of the platform targeted. We infer x86 by default.

I believe if you set <PlatformTarget>x64</PlatformTarget>, your project should work again, as suggested by @am11. Can you try that out?

cc @nguerrera as this can be related to inference. Though, in this case, I am not sure there is anything else we can do besides the work-around above.

nguerrera commented 6 years ago

Platform x64 should have implied PlatformTarget x64. I'll have to check out the repro.

chtenb commented 3 years ago

What is the difference between Platform and PlatformTarget? I'm very confused.