Showing posts with label Resharper. Show all posts
Showing posts with label Resharper. Show all posts

Sunday, February 26, 2017

Run .NET Core xUnit tests from ReSharper in VS2015

Visual Studio 2017 is literally only a few days away from release; so it might be a little late, but I finally figured out how to run .NET Core xUnit tests from ReSharper in VS2015! Good News: If you can't upgrade to VS2017 right away, then at least you can still run your unit tests!

Just make sure that the following is included in your project.json file (with the appropriate runtime):

{
  "testRunner": "xunit",
 
  "dependencies": {
    "dotnet-test-xunit": "2.2.0-preview2-build1029",
    "xunit": "2.2.0"
  },
 
  "frameworks": {
    "netcoreapp1.0": {
      "imports": "dnxcore50"
    }
  },
 
  "runtimes": {
    "win10-x64": {}
  }
}

Enjoy,
Tom

Tuesday, October 14, 2014

Share ReSharper and StyleCop Configuration via NuGet

Would you to share your coding style standards between projects?

Tools such as ReSharper and StyleCop both allow you to share your settings files between projects by placing a configuration file in the solution directory. However just sharing those settings across projects in a single solution might not be enough to truly enforce your coding standards for a whole team.

You can share your configuration settings across multiple solutions via a NuGet package. These configuration files can not just be standard content files in your NuGet package, they need to be installed via the init PowerShell script inside of the package.

Init.ps1

param($installPath, $toolsPath, $package)
 
Write-Host "==================================="
Write-Host "Initing: CSharpConventions"
 
# Get the active solution
$solution = Get-Interface $dte.Solution ([EnvDTE80.Solution2])
$solutionDir = Get-Item $solution.FullName
 
# Copy StyleCopy file
$copFileName = "Settings.StyleCop"
$newCopPath = join-path $solutionDir.Directory $copFileName
$oldCopPath = join-path $toolsPath $copFileName
Write-Host "Copying " $oldCopPath " to " $newCopPath
Copy-Item $oldCopPath $newCopPath 
 
# Copy and rename DotSettings file
$newDotPath = $solution.FullName + ".DotSettings"
$oldDotPath = join-path $toolsPath "Solution.sln.DotSettings"
Write-Host "Copying " $oldDotPath " to " $newDotPath
Copy-Item $oldDotPath $newDotPath 
 
Write-Host "Completed: CSharpConventions"
Write-Host "====================================="

NuSpec File

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
    <metadata>
        <id>CSharpConventions</id>
        <version>1.0.0</version>
        <authors>tdupont</authors>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <description>
            StyleCop and R# settings file to enforce C# coding standards.
        </description>
    </metadata>
    <files>
        <file src="tools\init.ps1" target="tools\init.ps1" />
        <file src="tools\Settings.StyleCop" 
            target="tools\Settings.StyleCop" />
        <file src="tools\Solution.sln.DotSettings" 
            target="tools\Solution.sln.DotSettings" />
    </files>
</package>

Enjoy,
Tom

Thursday, September 11, 2014

Decompile Methods with ReSharper

ReSharper is an amazing tool that .NET developers should never be without. One of my favorite features that if offers is build in support for decompiling methods when navigating to source. Enabling this option will literally allow you to view external source code simply by going to definition.

To enable this option, go to...

  1. Open the "ReSharper" Drop Down
  2. Select "Options"
  3. Expand "Tools"
  4. Select "External Sources"
  5. Select "Navigation to Sources"
  6. Check "Decompile methods"
  7. Save, and you're done!

Would you like to do this outside of Visual Studio as well? Check out JetBrains FREE decompiler tool, dotPeek.

Enjoy,
Tom

Friday, October 26, 2012

xUnit Visual Studio Integration

Good news, everyone! It is actually very easy to get xUnit completely integrated with Visual Studio. You only need to install two plugins...

VS2010 - xUnit Test Runner Extension

This will support running tests with a Visual Studio test project.
This includes all of the VS features, such as code coverage!

https://github.com/quetzalcoatl/xvsr10/downloads

ReSharper - xUnit Contrib Plugin

This will allow ReSharper to detect and run xUnit tests.

http://xunitcontrib.codeplex.com/releases/view/92101
(If you are still running Resharper 6, then you will need the latest: v6.1.1)

Team Build (TFS) Integration

Integrating with xUnit your Team Foundation Server is a very tricky proposition, but it can be done. That, however, is a (rather long) blog post for another day!

Shout it

Enjoy,
Tom

Real Time Web Analytics