MSB3270: Mismatch between the processor architecture - Fakes Framework

前端 未结 5 630
轮回少年
轮回少年 2020-12-29 04:37

Since I use Fakes Framework in my UnitTest, I get the following MSBuild warning.

warning MSB3270: There was a mismatch between the processor architect

相关标签:
5条回答
  • 2020-12-29 04:51

    For anyone that landed here and has nothing to do with "Fakes", check for warnings / errors in your References. I found a ghost DLL that fortunately the project did not require, and removed it. Worked great!

    0 讨论(0)
  • 2020-12-29 04:53

    I have got a response from Microsoft for this issue

    http://connect.microsoft.com/VisualStudio/feedback/details/804933/msb3270-mismatch-between-the-processor-architecture-fakes-framework

    Visual Studio 2012:

    Create the following element in “Fakes\MSBErrorTestClass.fakes” file under 'Fakes' node:

    <Compilation>
     <Property Name=”PlatformTarget”>x86</Property>
    </Compilation>
    

    Visual Studio 2013:

    This issue has been fixed in the latest release i.e. Visual Studio 2013

    0 讨论(0)
  • 2020-12-29 05:03

    In project_name.csproj file remove ItemGroup node where is set processorArchitecture attribute. It sth like;

    <ItemGroup> <Reference ... , processorArchitecture=MSIL"> ... </ItemGroup>

    That helped for me.

    0 讨论(0)
  • 2020-12-29 05:06

    Since I'm getting this error only for Fakes assemblies that I will only be running unit tests on, I decided to just ignore this error. This can be accomplished by adding this to your Fakes XML:

    <Fakes xmlns="http://schemas.microsoft.com/fakes/2011/">
      <Assembly Name="FakedAssemblyName.dll"/>
      <Compilation>
        <Property Name="ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch">None</Property>
      </Compilation>
    </Fakes>
    
    0 讨论(0)
  • 2020-12-29 05:09

    Did you use 3rd party libraries? If you use them, check them to see if they use the same x86 as the target processor. It is clear that the targeted processor should be the same for all of the references, not just the target of your project.

    UPDATE: Apparently this guy from Microsoft is experiencing this also. You can try to use his workaround:

    http://blogs.msdn.com/b/astebner/archive/2012/05/03/10300809.aspx

    From the blog entry, do this: Search for this "PlatformTarget" in your csproj file, and edit it to match this:

    <PlatformTarget Condition=" '$(PlatformTarget)' == '' ">x86</PlatformTarget>
    

    Let me know if this solve your problem.

    UPDATE 2: Based on your source code of the unittest.csproj and the classlib.csproj, the configuration is still based on "AnyCPU".

    Please look for this line:

    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    

    And also this line:

    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    

    Those target platform should also be set to use x86.

    The easier way is by setting the Debug and Release by clicking "Configuration Manager..." at "Debug" combobox on Visual Studio toolbar, like in this rough illustration:

    Visual Studio 2012 Debug/Release

    0 讨论(0)
提交回复
热议问题