I am trying to write a custom task in my MSBuild file to compress some js files with Google Closure Compiler. I downloaded the ClosureCompiler.dll and ClosureCompiler.tasks files from the site and have kept them in a folder on my m/c. I added the below lines in my csproj file
<Import Project="C:\Projects\Closure\ClosureCompiler.tasks" />
<Target Name="AfterBuild">
<ItemGroup>
<JS Include="test.js" />
</ItemGroup>
<ClosureCompiler CompilationLevel="SIMPLE_OPTIMIZATIONS" SourceFiles="@(JS)" SourceExtensionPattern="\.js$" TargetExtension=".min.js" />
</Target>
The test.js file is kept on the root of my project files. I do not want to include the optional ApiUrl since I want to compress files locally using ClosureCompiler.dll. The ClosureCompiler.tasks file is
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="ClosureCompiler" AssemblyFile="C:\Projects\Closure\ClosureCompiler.dll" />
</Project>
However when I try to compile the project, it gives me an error:
Compilation Failed: test.js, Reason: Object reference not set to instance of an object
Can anyone help as to what is the issue or what am I doing wrong?