Подтвердить что ты не робот

MSB3270: несоответствие между архитектурой процессора - Fakes Framework

Поскольку я использую Fakes Framework в своем модуле UnitTest, я получаю следующее предупреждение MSBuild.

warning MSB3270: между процессорной архитектурой создаваемого проекта "MSIL" и процессорной архитектурой эталонной "DocumentServiceModel", "x86" было обнаружено несоответствие между архитектурой процессора. Это несоответствие может привести к сбоям во время выполнения. Пожалуйста, подумайте об изменении целевой архитектуры процессора вашего проекта через Configuration Manager, чтобы согласовать архитектуры процессоров между вашим проектом и ссылками или зависеть от ссылок на архитектуру процессора, которая соответствует целевой архитектуре процессора вашего проекта. [C:\Projekte\XXX\XXX\XXX\Source\Testing\UT\XXX.UnitTest\OBJ\Debug\Подделки\ППСМ\f.csproj]

Цель платформы для всех проектов в решении установлена ​​на x86.

Как я могу избавиться от этого предупреждения сборки?

Update1:

Я думаю, проблема в том, что Fakes Framework создает динамический проект с целевой платформой "Любой процессор".

(C:\Projekte\XXX\XXX\XXX\Source\Testing\UT\XXX.UnitTest\OBJ\Debug\Подделки\ППСМ\f.csproj)

Этот динамический проект ссылается на сборки из моего проекта, который работает с целевой платформой "x86" .

Я понятия не имею, как изменить динамический Fakes projekt на "x86" .

UPDATE2:

Я создал образец проекта, и я получаю такое же предупреждение:

Warning 1   There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "MSBErrorTest", "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. [C:\Projekte\MSBErrorTest\UnitTestProject1\obj\Debug\Fakes\msbet\f.csproj] UnitTestProject1

UnitTest csproj:

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup>
        <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
        <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
        <ProjectGuid>{4B14EC56-DDC7-4A16-92BA-2D2881E695D1}</ProjectGuid>
        <OutputType>Library</OutputType>
        <AppDesignerFolder>Properties</AppDesignerFolder>
        <RootNamespace>UnitTestProject1</RootNamespace>
        <AssemblyName>UnitTestProject1</AssemblyName>
        <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
        <FileAlignment>512</FileAlignment>
        <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
        <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
        <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
        <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
        <IsCodedUITest>False</IsCodedUITest>
        <TestProjectType>UnitTest</TestProjectType>
      </PropertyGroup>
      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
        <DebugSymbols>true</DebugSymbols>
        <DebugType>full</DebugType>
        <Optimize>false</Optimize>
        <OutputPath>bin\Debug\</OutputPath>
        <DefineConstants>DEBUG;TRACE</DefineConstants>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel>
        <PlatformTarget>x86</PlatformTarget>
      </PropertyGroup>
      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
        <DebugType>pdbonly</DebugType>
        <Optimize>true</Optimize>
        <OutputPath>bin\Release\</OutputPath>
        <DefineConstants>TRACE</DefineConstants>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel>
        <PlatformTarget>x86</PlatformTarget>
      </PropertyGroup>
      <ItemGroup>
        <Reference Include="Microsoft.QualityTools.Testing.Fakes, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
        <Reference Include="MSBErrorTest.Fakes">
          <HintPath>FakesAssemblies\MSBErrorTest.Fakes.dll</HintPath>
        </Reference>
        <Reference Include="System" />
      </ItemGroup>
      <Choose>
        <When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
          <ItemGroup>
            <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
          </ItemGroup>
        </When>
        <Otherwise>
          <ItemGroup>
            <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
          </ItemGroup>
        </Otherwise>
      </Choose>
      <ItemGroup>
        <Compile Include="UnitTest1.cs" />
        <Compile Include="Properties\AssemblyInfo.cs" />
      </ItemGroup>
      <ItemGroup>
        <ProjectReference Include="..\MSBErrorTest\MSBErrorTest.csproj">
          <Project>{f1ae6c89-6f6a-404e-b9e2-10ee2f66942f}</Project>
          <Name>MSBErrorTest</Name>
        </ProjectReference>
      </ItemGroup>
      <ItemGroup>
        <Fakes Include="Fakes\MSBErrorTest.fakes" />
      </ItemGroup>
      <Choose>
        <When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
          <ItemGroup>
            <Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
              <Private>False</Private>
            </Reference>
            <Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
              <Private>False</Private>
            </Reference>
            <Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
              <Private>False</Private>
            </Reference>
            <Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
              <Private>False</Private>
            </Reference>
          </ItemGroup>
        </When>
      </Choose>
      <Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
      <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
      <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
           Other similar extension points exist, see Microsoft.Common.targets.
      <Target Name="BeforeBuild">
      </Target>
      <Target Name="AfterBuild">
      </Target>
      -->
    </Project>

ClassLib csproj:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{F1AE6C89-6F6A-404E-B9E2-10EE2F66942F}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>MSBErrorTest</RootNamespace>
    <AssemblyName>MSBErrorTest</AssemblyName>
    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <PlatformTarget>x86</PlatformTarget>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <PlatformTarget>x86</PlatformTarget>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Core" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Class1.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>

Update3:

Я изменил конфигурацию, чтобы выглядеть так.

  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\x86\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <DebugType>full</DebugType>
    <PlatformTarget>x86</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>

Но я все еще получаю предупреждение

4b9b3361

Ответ 1

У меня есть ответ от Microsoft для этой проблемы

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

Visual Studio 2012:

Создайте следующий элемент в файле "Fakes\MSBErrorTestClass.fakes" в разделе "Подделки" node:

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

Visual Studio 2013:

Эта проблема исправлена ​​в последней версии, то есть Visual Studio 2013

Ответ 2

Поскольку я получаю эту ошибку только для сборок сборки, на которых я буду запускать модульные тесты, я решил просто проигнорировать эту ошибку. Это можно сделать, добавив это в ваш Fakes XML:

<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/">
  <Assembly Name="FakedAssemblyName.dll"/>
  <Compilation>
    <Property Name="ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch">None</Property>
  </Compilation>
</Fakes>

Ответ 3

Использовали ли вы сторонние библиотеки? Если вы их используете, проверьте их, чтобы они использовали тот же x86, что и целевой процессор. Понятно, что целевой процессор должен быть одинаковым для всех ссылок, а не только для цели вашего проекта.

UPDATE: Очевидно, этот парень из Microsoft тоже это переживает. Вы можете попытаться использовать его обходное решение:

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

Из записи в блоге сделайте следующее: Найдите этот " PlatformTarget" в вашем файле csproj и отредактируйте его так:

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

Сообщите мне, если это решит вашу проблему.

ОБНОВЛЕНИЕ 2: на основе исходного кода unittest.csproj и classlib.csproj конфигурация по-прежнему основана на "AnyCPU".

Пожалуйста, найдите эту строку:

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

А также эта строка:

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

Для этой целевой платформы также необходимо установить x86.

Более простой способ - установить Debug и Release, щелкнув "Configuration Manager..." в "Debug" combobox на панели инструментов Visual Studio, как на этой примерной иллюстрации:

Visual Studio 2012 Debug/Release

Ответ 4

В файле project_name.csproj удалите узел ItemGroup где установлен атрибут processorArchitecture. Это как;

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

Это помогло мне.

Ответ 5

Для тех, кто приземлился здесь и не имеет никакого отношения к "Подделкам", проверьте наличие предупреждений/ошибок в своих ссылках. Я нашел библиотеку-призрак, которая, к счастью, не требовалась проекту, и удалил ее. Работал отлично!