06 June 2014

Visual Studio 2013 Setup and New Project/Solution Notes

There are a few things I like to do when I set up a new project and sometimes forget one or two of them so here is a check-list I've made for myself as much as anything else.

NB: Only install the extensions/tools you actually need as every one you install will slow VS down.

Visual Studio Setup/Extensions

Updates

I usually find a new version of Visual Studio requires updates. Check both Windows Update and Visual Studio > Tools > Extensions and Updates.
NB: the VS Update 4 had a bug when I tried to install it that means it never finishes. I had to download it as an ISO.

Version Control

TFS: integrated into VS, or via explorer from the TFS install CD, or web access.
Git:I usually install a local Git UI (e.g. Tortoise port) as well as relying on VS's integrated control.
Subversion: Tortoise SVN and VS extension.

Visual Studio Spell Checker

Install this and get little pink lines under misspelt words. The dictionary is customisable Tools > Spell Checker > Edit Configuration.

ReSharper

Be sure to enable StyleCop integration or they will fight:
Environment > Plugins > StyleCop

NCrunch

I love this tool for continuous testing and test coverage feedback. It is a bit resource hungry but it's worth it for me.

NUnit Test Adapater

Needed for the Visual Studio Test Explorer to run NUnit tests e.g. to see code coverage results.

Code Coverage

Visual Studio Premium or Ultimate: built in under Test > Analyse Code Coverage.
Otherwise use OpenCover or proprietary JetBrains dotcover or similar.

Continuous Integration

Depends on what you are using but there is an extension for TeamCity.

StyleCop

Adds various (customisable) code styling rules to your IDE. Useful to keep teams styles synonymous.

GhostDoc

Some like documenting code, others don't. Auto documented code is usually useless but for me, GhostDoc gives a good starting point.

New Project/Solution

Creating New Project

When creating a new project if you're going to have more than one project ensure you select 'create directory for solution' then create your project e.g.
Project name: MyCompany.MyProject.UnitTests
Solution name: 
MyCompany.MyProject
Also ensure 'Add to source control' is selected if you need it. 

Solution Items

ReadMe: I like to add a simple text file into the Solution root which contains any solution specific notes for yourself or another developer e.g. if it has any specific requirements like running VS as admin.

License: If it's going off into the world e.g. onto GitHub make sure you add a license e.g. MIT

Nuget Package Restore

Right click solution and enable package restore. In the resulting .nuget/NuGet.targets file edit the following under Project/PropertyGroup:
RestorePackages: true
DownloadNuGetExe: false

Version Control

Add the solution to TFS, Git or Subversion. Personally I work off grid quite a lot so I like Git so I can run a local repository and a remote one. 

Git

If you're using Git do change the default .gitignore to ignore your packages sub folders but include the pacakges/repositories.config file.

StyleCop

Put the majority of settings in the solution root, and simple StyleCop config files in the other projects if project specific settings are required e.g. no comments required for Test projects. See the Appendix for suggested individual settings templates.
NB: to change a solution setting I usually note the SA number, edit it in a project (right click project in Solution explorer, StyleCop settings) then cut/paste the result in the project's settings file to the solution settings file.

Appendix

StyleCop Solution Settings

<StyleCopSettings Version="105">
  <GlobalSettings>
    <CollectionProperty Name="RecognizedWords">
      <Value>authorised</Value>
      <Value>behaviour</Value>
      <Value>initialise</Value>
      <Value>initialising</Value>
    </CollectionProperty>
  </GlobalSettings>

  <SourceFileList>
    <SourceFile>AssemblyInfo.cs</SourceFile>
    <Settings>
      <GlobalSettings>
        <BooleanProperty Name="RulesEnabledByDefault">False</BooleanProperty>
      </GlobalSettings>
    </Settings>
  </SourceFileList>

  <Analyzers>

    <Analyzer AnalyzerId="StyleCop.CSharp.DocumentationRules">
      <Rules>
        <Rule Name="ConstructorSummaryDocumentationMustBeginWithStandardText">
          <RuleSettings>
            <BooleanProperty Name="Enabled">False</BooleanProperty>
          </RuleSettings>
        </Rule>
        <Rule Name="ElementDocumentationMustHaveSummary">
          <RuleSettings>
            <BooleanProperty Name="Enabled">False</BooleanProperty>
          </RuleSettings>
        </Rule>
        <Rule Name="ElementsMustBeDocumented">
          <RuleSettings>
            <BooleanProperty Name="Enabled">False</BooleanProperty>
          </RuleSettings>
        </Rule>
        <Rule Name="EnumerationItemsMustBeDocumented">
          <RuleSettings>
            <BooleanProperty Name="Enabled">False</BooleanProperty>
          </RuleSettings>
        </Rule>
        <Rule Name="FileMustHaveHeader">
          <RuleSettings>
            <BooleanProperty Name="Enabled">False</BooleanProperty>
          </RuleSettings>
        </Rule>
        <Rule Name="PartialElementsMustBeDocumented">
          <RuleSettings>
            <BooleanProperty Name="Enabled">False</BooleanProperty>
          </RuleSettings>
        </Rule>
        <Rule Name="PartialElementDocumentationMustHaveSummary">
          <RuleSettings>
            <BooleanProperty Name="Enabled">False</BooleanProperty>
          </RuleSettings>
        </Rule>
        <Rule Name="ElementDocumentationMustHaveSummaryText">
          <RuleSettings>
            <BooleanProperty Name="Enabled">False</BooleanProperty>
          </RuleSettings>
        </Rule>
        <Rule Name="PartialElementDocumentationMustHaveSummaryText">
          <RuleSettings>
            <BooleanProperty Name="Enabled">False</BooleanProperty>
          </RuleSettings>
        </Rule>
        <Rule Name="ElementDocumentationMustNotHaveDefaultSummary">
          <RuleSettings>
            <BooleanProperty Name="Enabled">False</BooleanProperty>
          </RuleSettings>
        </Rule>
        <Rule Name="ElementParametersMustBeDocumented">
          <RuleSettings>
            <BooleanProperty Name="Enabled">False</BooleanProperty>
          </RuleSettings>
        </Rule>
        <Rule Name="ElementReturnValueMustBeDocumented">
          <RuleSettings>
            <BooleanProperty Name="Enabled">False</BooleanProperty>
          </RuleSettings>
        </Rule>
      </Rules>
      <AnalyzerSettings>
        <BooleanProperty Name="IgnorePrivates">True</BooleanProperty>
        <BooleanProperty Name="IncludeFields">False</BooleanProperty>
      </AnalyzerSettings>
    </Analyzer>
  </Analyzers>

  <Parsers>
    <Parser ParserId="StyleCop.CSharp.CsParser">
      <ParserSettings>
        <BooleanProperty Name="AnalyzeDesignerFiles">False</BooleanProperty>
      </ParserSettings>
    </Parser>
  </Parsers>

</StyleCopSettings>

Normal project

This settings file allows you to have specifc settings for the project e.g. documentation.and inherits the settings from the StyleCop solution settings.
<StyleCopSettings Version="105">
</StyleCopSettings>

StyleCop Test Project

<StyleCopSettings Version="105">
<Analyzers>
<Analyzer AnalyzerId="StyleCop.CSharp.DocumentationRules">
<Rules>
<Rule Name="ElementsMustBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
</Analyzers>
</StyleCopSettings>

No comments:

Post a Comment