locked
Visual Studio creates project configuration that generates the error "/platform:anycpu32bitpreferred is not a valid setting" RRS feed

  • Question

  • The Problem

    When I create a new project configuration and then attempt to compile the project, I get the error:

      /platform:anycpu32bitpreferred is not a valid setting for option /target:library or /target:module

    This seems to happen more often with VS 2012 RC Professional and less with VS 2012 RC Express.

    There's a workaround of deleting the project configuration, then creating it again - but it sometimes takes a few tries.  Another workaround is to manually create the project configurations by editing the .csproj xml and copying around project configurations.  

    Details

    1. Create a new winRT C# project.  Save the solution.
    2. Right click on the solution > Configuration Manager.
    3. Under "Active Solution Configuration", choose "New".  
        Set the "Name" to "Local", set the "Copy Settings" from "Debug".
        Check "Create new project configurations"
    4. Repeat steps 2 and 3, create a new "Local2" configuration copied from "Local".
    5. Compile and you get the error "/platform:anycpu32bitpreferred is not a valid setting for option /target:library or /target:module "

    This doesn't always happen, but it happens every once in a while.
    Does anyone know if there's a way to avoid this error?  Will this be fixed in RTM?

    This is a configuration that works -

      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Local|AnyCPU' ">
        <DebugSymbols>true</DebugSymbols>
        <DebugType>full</DebugType>
        <Optimize>false</Optimize>
        <OutputPath>bin\Local\</OutputPath>
        <DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel>
        <DocumentationFile>bin\Local\MyProject.XML</DocumentationFile>
      </PropertyGroup>

    This is a configuration created by Visual Studio that does not work -

      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Local|AnyCPU' ">
        <DebugSymbols>true</DebugSymbols>
        <OutputPath>bin\Local\</OutputPath>
        <DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
        <DocumentationFile>bin\Local\MyProject.XML</DocumentationFile>
        <NoStdLib>true</NoStdLib>
        <DebugType>full</DebugType>
        <PlatformTarget>AnyCPU</PlatformTarget>
        <UseVSHostingProcess>false</UseVSHostingProcess>
        <ErrorReport>prompt</ErrorReport>
        <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
        <Prefer32Bit>true</Prefer32Bit>
      </PropertyGroup>

    I'm not sure why Visual Studio creates working configuration sometimes and sometimes it goes bezerk and creates something that doesn't compile.
    Friday, July 27, 2012 6:08 AM

Answers

  • Hello Emmanuel,

    I think this fixed in a future build of VS 2012 based on the similarity of your repro steps to a bug I see in our database.  I need to get that build installed to verify.

    Does this workaround avoid the error

    Open the project file in notepad and remove <Prefer32Bit>true</Prefer32Bit> then reload it  (you can also right click on the project in solution explorer, choose unload project, right click on the project again, choose edit someproject.csproj, after making the edit, save, and right click and reload.

    That will be added proof that it is similar to the bug you are running into.  Once I get a newer build of Windows 8/Visual Studio 2012, I will be able to double check.

    the bug has something to do with the internal initialization of that particular setting which might explain the intermittent nature you are seeing.

    much appreciated,

    mike

    • Marked as answer by Min ZhuMember Friday, August 3, 2012 6:11 AM
    Tuesday, July 31, 2012 9:14 PM
    Moderator
  • Yes, that was it!  Visual Studio 2012 is adding "<Prefer32Bit>true</Prefer32Bit>" to the "AnyCPU" project configuration.  Once removed, the project compiled.  Nicely done, Mike.

    I'll be really happy when VS 2012 RTM is available on MSDN. :-)

    Wednesday, August 8, 2012 6:18 AM

All replies

  • Really, no answer from the Microsoft folks?

    This was an issue in the consumer preview and release preview versions - if you don't address it will be an issue for the rtm version as well.

    Tuesday, July 31, 2012 7:30 AM
  • Hello Emmanuel,

    I think this fixed in a future build of VS 2012 based on the similarity of your repro steps to a bug I see in our database.  I need to get that build installed to verify.

    Does this workaround avoid the error

    Open the project file in notepad and remove <Prefer32Bit>true</Prefer32Bit> then reload it  (you can also right click on the project in solution explorer, choose unload project, right click on the project again, choose edit someproject.csproj, after making the edit, save, and right click and reload.

    That will be added proof that it is similar to the bug you are running into.  Once I get a newer build of Windows 8/Visual Studio 2012, I will be able to double check.

    the bug has something to do with the internal initialization of that particular setting which might explain the intermittent nature you are seeing.

    much appreciated,

    mike

    • Marked as answer by Min ZhuMember Friday, August 3, 2012 6:11 AM
    Tuesday, July 31, 2012 9:14 PM
    Moderator
  • Yes, that was it!  Visual Studio 2012 is adding "<Prefer32Bit>true</Prefer32Bit>" to the "AnyCPU" project configuration.  Once removed, the project compiled.  Nicely done, Mike.

    I'll be really happy when VS 2012 RTM is available on MSDN. :-)

    Wednesday, August 8, 2012 6:18 AM