Skip to content

Instantly share code, notes, and snippets.

@akimboyko
Last active July 26, 2016 20:08
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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=0.1.11.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'FSharpLint.Application, Version=0.1.11.0, 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'">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\FSharpLint.0.1.11\build\FSharpLint.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\FSharpLint.0.1.11\build\FSharpLint.targets'))" />
</Target>
<!-- 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">
</Target>
-->
<UsingTask AssemblyFile="..\packages\FSharpLint.0.1.11\FSharpLint.MSBuildIntegration.dll" TaskName="FSharpLintTask" Condition="'$(NCrunch)' != '1'" />
<Target Name="AfterBuild">
<FSharpLintTask Project="$(MSBuildProjectFullPath)" Condition="'$(NCrunch)' != '1'"/>
</Target>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment