Skip to content

Commit c0f7eb9

Browse files
committed
added documentation for disabling TypeScript Build in VS
1 parent 3d6dc7b commit c0f7eb9

File tree

4 files changed

+54
-2
lines changed

4 files changed

+54
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,8 @@ grunt.initConfig({
327327
});
328328
````
329329

330+
If you wish to disable the Visual Studio built-in TypeScript build, but keep the Visual Studio project properties TypeScript Build pane working, follow [these instructions](./docs/DisableVisualStudioBuild.md).
331+
330332

331333
#### watch
332334

custom.TypeScript.targets

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<PropertyGroup>
3+
<CfgPropertyPagesGuidsAddCSharp>{d4683cae-88c4-4b85-863d-ac8014f3ba36}</CfgPropertyPagesGuidsAddCSharp>
4+
<CfgPropertyPagesGuidsAddVB>{d4683cae-88c4-4b85-863d-ac8014f3ba36}</CfgPropertyPagesGuidsAddVB>
5+
<CfgPropertyPagesGuidsAddTypeScript>{d4683cae-88c4-4b85-863d-ac8014f3ba36}</CfgPropertyPagesGuidsAddTypeScript>
6+
</PropertyGroup>
7+
<ItemGroup>
8+
<ProjectCapability Include="TypeScript" />
9+
</ItemGroup>
10+
<PropertyGroup>
11+
<TypeScriptEnabled>true</TypeScriptEnabled>
12+
</PropertyGroup>
13+
</Project>

docs/DisableVisualStudioBuild.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# How to disable the Visual Studio TypeScript Build
2+
*but keep the TypeScript Project Properties Pane Working...*
3+
4+
If you are using Visual Studio and wish to compile your TypeScript with grunt-ts *only*, you can disable the Visual Studio TypeScript build by performing the following steps:
5+
6+
* First, make sure your project has TypeScript support enabled by opening the project properties and confirming that the TypeScript Build properties pane is selectable.
7+
* Next, make sure your project folder has grunt-ts installed, and confirm that running grunt with the appropriate configuration will compile your project correctly.
8+
* Exit Visual Studio (Targets are only read once, so unloading the project is not sufficient).
9+
* Make sure that your project is backed-up or fully checked-in to Source Control.
10+
* Edit the .csproj or .vbproj file for which you wish to disable VS TypeScript building.
11+
* Search for the line containing the text "Microsoft.TypeScript.targets". Delete or comment-out the entire line.
12+
* At that spot, add one of these lines:
13+
14+
**If grunt-ts is installed in node_modules under the Project folder:**
15+
```xml
16+
<Import Project="$(ProjectDir)\node_modules\grunt-ts\custom.TypeScript.targets" Condition="Exists('$(ProjectDir)\node_modules\grunt-ts\custom.TypeScript.targets')" />
17+
```
18+
19+
**If grunt-ts is installed in node_modules under the Solution folder:**
20+
```xml
21+
<Import Project="$(SolutionDir)\node_modules\grunt-ts\custom.TypeScript.targets" Condition="Exists('$(SolutionDir)\node_modules\grunt-ts\custom.TypeScript.targets')" />
22+
```
23+
24+
**If grunt-ts is installed elsewhere**
25+
Modify one of the previous examples to point to the `custom.TypeScript.targets` file.
26+
27+
* If you have multiple projects in your solution, you must edit each .csproj or .vbproj.
28+
* Reload Visual Studio and confirm that the TypeScript Build pane still appears in the project properties.
29+
* Then, introduce an error in a TypeScript file such as a mismatched parenthesis.
30+
* Finally, press Ctrl+Shift+B to initiate a build. If the build succeeds, you've successfully disabled the TypeScript compilation in Visual Studio. Run Grunt to build your project and it should fail. Fix the error and Grunt should then succeed (assuming it was prior to you making these changes).
31+
32+
33+
34+

grunt-ts.csproj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,12 @@
9090
<Content Include="tsd.json" />
9191
<Content Include="tslint.json" />
9292
</ItemGroup>
93-
<ItemGroup />
93+
<ItemGroup>
94+
<Content Include="docs\DisableVisualStudioBuild.md" />
95+
</ItemGroup>
9496
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
9597
<TypeScriptTarget>ES3</TypeScriptTarget>
9698
</PropertyGroup>
97-
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets')" />
99+
<!-- <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets')" /> -->
100+
<Import Project="$(ProjectDir)\custom.TypeScript.targets" Condition="Exists('$(ProjectDir)\custom.TypeScript.targets')" />
98101
</Project>

0 commit comments

Comments
 (0)