none
VS 2015 Project File loading incorrect $(Platform)

    Question

  • I need to load one dll for x86 projects and another dll for x64 projects as a reference to a project. I was previously using VS 2008 and could do the following:

      <PropertyGroup Condition=" '$(Platform)' == 'x64' ">
        <ClearRef>..\..\..\mypath\x64\mydll64.dll</ClearRef>
      </PropertyGroup>
      <PropertyGroup Condition=" '$(Platform)' == 'x86' ">
        <ClearRef>..\..\..\mypath\x86\mydll.dll</ClearRef>
      </PropertyGroup>
      <ItemGroup>
        <Reference Include="mydll">
          <HintPath>$(ClearRef)</HintPath>
        </Reference>
        <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.Net.Http" />
        <Reference Include="System.Xml" />
      </ItemGroup>

    However since upgrading to VS 2015 Update 3, $(Platform) is always set to "AnyCPU", no matter what configuration and platform I target.

    Is there a fix or workaround for this? I was able to reproduce it creating a brand new solution.

    Wednesday, November 2, 2016 9:36 PM

All replies

  • Hi erikotto,

    According to your description, you could modify the .csproj file with the following steps:

    1.Right click on your project in solution explorer and select Unload Project;

    2.Right click on the project-> Edit ***.csproj. This will open up your .csproj file for editing.

    3.After modifying, save and close the file. Right click the project again on the node and choose Reload Project.

    Sincerely,

    Oscar


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Thursday, November 3, 2016 5:25 AM
    Moderator
  • This is what I did, but for some reason $(Platform) is always "AnyCPU" when I target both the solution and project to x64.

    I tried to reproduce using a brand new solution and one empty project with one reference. Creating a brand new 2015 project it seemed to work perfectly. Then I tried creating a brand new 2008 project and upgrading it to 2015 and I am seeing this issue where the projects $(Platform) seems to always think it's running as AnyCPU.

    I can provide the simple test project I tested with if that helps.

    Thursday, November 3, 2016 4:54 PM
  • Hi erikotto,

    We could modify the default .csproj file for different projects when we create it. Here just like a class library project. Find the default .csproj file in the following path (my computer is x64):

    C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\ProjectTemplates\CSharp\Windows Root\Windows\1033\ClassLibrary\classlibrary.csproj

    Then modify the classlibrary.csproj file with Notepad (in administrator mode), after changing please save and close. Before modifying please back up it. Then when you create a new class library project and .csproj file is that your modified.

    But you want update the project from VS2008 to VS2015. You could try above steps first based on your situation, then update the VS2008 project to observe whether has the same issue.

    If it also does not work for you, I think VS could not implement this feature. Please feel free to let me know your latest results.

    Sincerely,

    Oscar


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, November 4, 2016 1:06 AM
    Moderator