I am running grunt and have set up a typescript build process that listens for file changes, therefore I don't need the default VS compilation of my typescript files when I save or build my project.
I have unchecked the 'Compile on save' option under typescript in my project properties, but the ts files are still being compiled. The only way this works for me is if I set the build action of individual TS files to 'None', but this is still causing some Typescript files to be compiled. Is there any way this can be done in VS2013?
Currently, there are a few ways to "disable TypeScript" in VS. You could go to Tools > Options > Text Editor > JavaScript/TypeScript > Project and uncheck the Project Analysis options.
TypeScript files are compiled to readable JavaScript, so that migration back is possible and understanding the compiled TypeScript is not hard at all.
In VS2015, a <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
setting can be added to the first <PropertyGroup>
element in .csproj
msbuild output should then show
PreComputeCompileTypeScript:
TypeScript compile is skipped because the TypeScriptCompileBlocked property is set to true.
From: http://rostacik.net/2015/08/14/how-to-disable-building-of-typescript-files-in-visual-studio-2015/
I had the same question and solution that I found is to override TypeScript targets in the VS project file:
<Target Name="PreComputeCompileTypeScript">
<Message Text="Skipping PreComputeCompileTypeScript" />
</Target>
<Target Name="CompileTypeScript">
<Message Text="Skipping CompileTypeScript" />
</Target>
<Target Name="GetTypeScriptCopyToOutputDirectoryItems">
<Message Text="Skipping GetTypeScriptCopyToOutputDirectoryItems" />
</Target>
@Christopher Mott answer works also for Visual Studio 2013, at least for Update 5 and TypeScript Tools for Microsoft Visual Studio 2013 1.8.5.0. To be sure, one could verify if VS TypeScript toolchain understands that flag:
Open .csproj
file for the intendend project and notice that it imports TypeScript targets from some:
$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets
that generally maps to:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\<your VS version number>\TypeScript\Microsoft.TypeScript.targets
Inspect that file and look for TypeScriptCompileBlocked
being defined (as false) in some <PropertyGroup>
. If it's there, you're sorted. Go back to .csproj
file and add the following, right after where TypeScript targets are imported:
<!-- Disable TypeScript compilation from within VS, leave that to external tools -->
<PropertyGroup>
<TypeScriptCompileBlocked>True</TypeScriptCompileBlocked>
</PropertyGroup>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With