We are looking to provide two custom Platform switches (the platform dropdown in the configuration manager) for our projects in Visual Studio.
For example one for 'Desktop' and one for 'Web'. The target build tasks then compile the code in a custom way based on the platform switch. We don't want to add to the Debug Release switch because we would need those for each Desktop and Web platforms.
We found one way to attempt this, is to modify the .csproj file to add something like this
<Platform Condition=" '$(Platform)' == '' ">Desktop</Platform>
and add propertygroups like,
<PropertyGroup Condition=" '$(Platform)' == 'Web' ">
<DefineConstants>/define Web</DefineConstants>
<PlatformTarget>Web</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'Desktop' ">
<DefineConstants>/define Desktop</DefineConstants>
<PlatformTarget>Desktop</PlatformTarget>
</PropertyGroup>
But still this doesn't work, and compiler throws an error
Invalid option 'Desktop' for /platform; must be anycpu, x86, Itanium or x64
So does it have to be one of those options and can't we add our custom platforms?
Has anyone been able to do this? any pointers would be helpful.
Update: Using DebugDesktop and ReleaseDesktop will make it more complicated for users. Because 'desktop' and 'web' are actually platforms and also there is ability to add new platforms in the dropdown (i.e. ), I believe 'platform' switch should be used for the exact same purpose.