Skip to content

Instantly share code, notes, and snippets.

Last active July 26, 2016 20:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akimboyko/b9ef29e54d5dc8b4bb10 to your computer and use it in GitHub Desktop.
Save akimboyko/b9ef29e54d5dc8b4bb10 to your computer and use it in GitHub Desktop.
How to disable FSharpLint while building using nCrunch?

Configure FSharpLint

Including The Task In Your Project's Project File Afterwards you will get following build error:

The "FSharpLintTask" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load file or assembly 'FSharpLint.Application, Version=, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'FSharpLint.Application, Version=, Culture=neutral, PublicKeyToken=null'

nCrunch conditional build behaviour

When executing any kind of build, NCrunch will always inject a special property that can be used to identify it during the build. The property is $(NCrunch) with a value of 1. Therefor you need to turn off FSharpLint while building with nChrunch. Anyway it has no sence :)

Use Condition="'$(NCrunch)' != '1'" with MSBuild XML nodes to disable execution for nCrunch and see MyProject.fsproj for more samples

<Import Project="..\packages\FSharpLint.0.1.11\build\FSharpLint.targets" Condition="Exists('..\packages\FSharpLint.0.1.11\build\FSharpLint.targets') And '$(NCrunch)' != '1'" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild" Condition="'$(NCrunch)' != '1'">
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see The missing file is {0}.</ErrorText>
<Error Condition="!Exists('..\packages\FSharpLint.0.1.11\build\FSharpLint.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\FSharpLint.0.1.11\build\FSharpLint.targets'))" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
<UsingTask AssemblyFile="..\packages\FSharpLint.0.1.11\FSharpLint.MSBuildIntegration.dll" TaskName="FSharpLintTask" Condition="'$(NCrunch)' != '1'" />
<Target Name="AfterBuild">
<FSharpLintTask Project="$(MSBuildProjectFullPath)" Condition="'$(NCrunch)' != '1'"/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment