Changing the PlatformTarget in Visual C# Express

January 18, 2010 .net msbuild

Some project types in Visual C# Express (Empty Project) will not allow you to change the PlatformTarget from the UI. You can still change the target platform though by editing the .csproj file in a text editor. Close the project and open it up in your favorite text editor (I use Notpad++). The .csproj file is really just a XML file. You should see somewhere in the file something like:

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

Inside the PropertyGroup elements, add the PlatformTarget element:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
		....
		<PlatformTarget>x86</PlatformTarget>
	</PropertyGroup>
	<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
		....
		<PlatformTarget>x86</PlatformTarget>
	</PropertyGroup>

Save the file and open your project back up. Your project's output should now target only x86.