Visual Studio - Move referenced DLL to different directory after Build

July 20, 2010 .net msbuild

If you need to move a referenced DLL to a different directory after build, add these commands to the "Post Build event command line" box in the "Build Events" tab of the project properties:

mkdir $(TargetDir)dir
move $(TargetDir)myDLL.dll $(TargetDir)dir\myDLL.dll

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.