C#, Visual Studio 2010, No more Client profile in 5minutes.

I guess I’m not alone being tired of running into the “Client profile” framework version used when creating a Console application in Visual Studio 2010. Don’t know how life is going to be in coming version of Visual Studio, but until then, lets show you a solution that takes no more than 5 minutes.

Step 1 – Locate the Project template shipped with Visual Studio

For me the installation set this up here: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ProjectTemplates\CSharp\Windows\1033

Step 2 – Edit the VS-Template file

Unzip the content of ConsoleApplication.zip to a temp location. Rename csConsoleApplication.vstemplate to csConsoleApplication-NoClientProfile.vstemplate. Open the file with a plain old text editor and make the following change. More info: http://msdn.microsoft.com/en-us/library/ms185291.aspx

Original

<?xml version="1.0" encoding="utf-8"?>
<VSTemplate Version="3.0.0" Type="Project" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
  <TemplateData>
    <Name Package="{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}" ID="2320" />
    <Description Package="{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}" ID="2321" />
    <Icon Package="{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}" ID="4548" />
    <TemplateID>Microsoft.CSharp.ConsoleApplication</TemplateID>
    <ProjectType>CSharp</ProjectType>
    <RequiredFrameworkVersion>2.0</RequiredFrameworkVersion>
    <SortOrder>12</SortOrder>
    <NumberOfParentCategoriesToRollUp>1</NumberOfParentCategoriesToRollUp>
    <CreateNewFolder>true</CreateNewFolder>
    <DefaultName>ConsoleApplication</DefaultName>
    <ProvideDefaultName>true</ProvideDefaultName>
  </TemplateData>
  <TemplateContent>
    <Project File="ConsoleApplication.csproj" ReplaceParameters="true">
      <ProjectItem ReplaceParameters="true" TargetFileName="Properties\AssemblyInfo.cs">AssemblyInfo.cs</ProjectItem>
      <ProjectItem ReplaceParameters="true" OpenInEditor="true">Program.cs</ProjectItem>
      <ProjectItem ReplaceParameters="true">App.config</ProjectItem>
    </Project>
  </TemplateContent>
</VSTemplate>

Change this
Provide new tags for:

<Name>
<Description>

Remove the tag:

<TemplateId>

Updated

<?xml version="1.0" encoding="utf-8"?>
<VSTemplate Version="3.0.0" Type="Project" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
  <TemplateData>
    <Name>ConsoleApplication-NoClientProfile</Name>
    <Description>Ordinary Console application but NO CLIENT PROFILE</Description>
    <Icon Package="{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}" ID="4548" />
    <ProjectType>CSharp</ProjectType>
    <RequiredFrameworkVersion>2.0</RequiredFrameworkVersion>
    <SortOrder>12</SortOrder>
    <NumberOfParentCategoriesToRollUp>1</NumberOfParentCategoriesToRollUp>
    <CreateNewFolder>true</CreateNewFolder>
    <DefaultName>ConsoleApplication</DefaultName>
    <ProvideDefaultName>true</ProvideDefaultName>
  </TemplateData>
  <TemplateContent>
    <Project File="ConsoleApplication.csproj" ReplaceParameters="true">
      <ProjectItem ReplaceParameters="true" TargetFileName="Properties\AssemblyInfo.cs">AssemblyInfo.cs</ProjectItem>
      <ProjectItem ReplaceParameters="true" OpenInEditor="true">Program.cs</ProjectItem>
      <ProjectItem ReplaceParameters="true">App.config</ProjectItem>
    </Project>
  </TemplateContent>
</VSTemplate>

Step 3 – Edit the CS-project file

Locate this section:

$if$ ($targetframeworkversion$ >= 4.0)
  <TargetFrameworkProfile>Client</TargetFrameworkProfile>
$endif$

and remove Client.

$if$ ($targetframeworkversion$ >= 4.0)
  <TargetFrameworkProfile></TargetFrameworkProfile>
$endif$

Step 4 – Zip and “install” the new template

Rezip the extracted files from Step 2 into a new file ConsoleApplication-NoClientProfile.zip and drop it into the folder that holds custom project templates for Visual Studio. For me this was: C:\Users\sedanwer\Documents\Visual Studio 2010\Templates\ProjectTemplates\Visual C#

More info: http://msdn.microsoft.com/en-us/library/y3kkate1.aspx

Step 5 – Consume it

The next time you start Visual Studio 2010 and do File – New project, you will now find your now project template under CSharp – Windows.

That’s it. Have fun!

//Daniel

About these ads

4 thoughts on “C#, Visual Studio 2010, No more Client profile in 5minutes.

  1. Pingback: Interesting .NET Links - January 9 , 2012 | Tech Blog

  2. Pingback: C#, Visual Studio 2010, No more Client profile... | .NET, Visual Studio 2010 | Syngu

  3. Pingback: The Morning Brew - Chris Alcock » The Morning Brew #1017

  4. Pingback: Some XSockets and SisoDb fun – Part 1 of 2 « Daniel Wertheim

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s