views:

20

answers:

2

Is there is a way to set the default build action to x86, instead of Any CPU in Visual Studio 2008?

That way all new projects will be compiled for x86, and great features like edit and continue will work.

Perhaps a registry hack or somthing simple, like a global option.

Thanks, Carl

A: 

maybe not that simple, but I start all my projects from a template; the template imports a default project like

<Import Project="..\template\defaults.csproj" />

and there the default platform is set to x86 (there is even no Any CPU):

<PropertyGroup>
  <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
  <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
  <!--goes on setting outputpath, default build options, ...-->
</PropertyGroup>

Upon loading a newly created project from this template, VS automatically takes Debug|x86 as config.

stijn
In doing this, do you have to provide a project template for every project type?
Carl Weis
what do you mean with project type?The template csproj is only 15 lines or so, it's just one <PropertyGroup> for the Guids, AssmblyName, OutputType and Versions, and the <Import> line I showed above. I guess this is all you need for any C# project?
stijn
WinForms, Console, WPF, etc.
Carl Weis
the only difference between a WinForms and WPF for example, are the included references. The structure of the project file is the same.
stijn
A: 

You could edit the project templates with, say, Notepad. They are located in Common7\IDE\ProjectTemplates(Cache)\CSharp\Windows\xxxx\*.zip. Edit the .csproj file in the .zip archive and add

<PlatformTarget>x86</PlatformTarget>

to the Debug and/or Release PropertyGroup.

Or consider upgrading to VS2010, x86 is now the default.

Hans Passant
Thanks. I have upgraded to 2010, but still need to work on some 2008 projects, without converting the project file.
Carl Weis