Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does gulp-typescript play nice with Visual Studio? #65

Closed
johnnyreilly opened this issue Jan 28, 2015 · 11 comments
Closed

Does gulp-typescript play nice with Visual Studio? #65

johnnyreilly opened this issue Jan 28, 2015 · 11 comments

Comments

@johnnyreilly
Copy link

Hi people!

I've just stumbled upon gulp-typescript as I was looking into some gulp related continuous release stuff.

This looks really interesting - my question is: is this only intended to be used outside of Visual Studio? Or if not, how does it fit in when used inside Visual Studio? Do you need to prevent VS from performing the compilation perhaps?

I think it might be beneficial (perhaps not only to me 😄) to enhance the readme.md to clarify this....

@ivogabe
Copy link
Owner

ivogabe commented Jan 31, 2015

You can use this with Visual Studio, but you need to make sure VS won't compile the .ts files. I don't know exactly how you should do that.. You can use windows power shell for example to run gulp, or maybe a gulp extension in Visual Studio, I don't know whether that exists.

I can add this to the readme if this solves your questions.

@xt0rted
Copy link

xt0rted commented Jan 31, 2015

Using the Task Runner Explorer, Grunt Launcher, and Package Intellisense extensions should give you everything you need to work almost entirely in VS2013 (this is all built in to 2015). And if you need to use the command line then the Open Command Line extension makes that a bit easier as well.

If you start using a setup like this you'll need to update all of your typescript files so their Build Action is set to Content. This is because even when Compile on save is disabled (project properties > typescript build) msbuild will continue to compile the files on each build. It's probably easiest to edit the project file directly and find & replace TypeScriptCompile to Content.

I'm not sure if this was unique to my setup or not but I'd recommend not running gulp as a post build step and instead do something like run gulp-watch on startup or from a console. When running gulp post build with F5 I found the site would start to load before gulp finished and then my css & js would return 404s.


Edit: This shows the features in VS2015 but using the extensions I mentioned above will give you almost the same functionality in VS2013.

@johnnyreilly
Copy link
Author

Thanks for the pointers. I'm already using gulp for js minification and concatenation with task runner extension. Was wondering about getting the TS compilation in the mix too.

Do you lose intellisense when you switch to content files? That'd be a blocker for me.

@xt0rted
Copy link

xt0rted commented Feb 2, 2015

I have ReSharper installed but I've disabled js & ts support since it doesn't support require() or ts1.4 so I'm using the built-in tooling and I'm getting IntelliSense in my gulpfile and typescript files just fine.

@johnnyreilly
Copy link
Author

Nice. (I've also disabled resharper for the same reasons)

@ivogabe
Copy link
Owner

ivogabe commented Mar 16, 2015

See microsoft/TypeScript#2326 for a proposal to make it easier to use gulp & Visual Studio together.

@johnnyreilly
Copy link
Author

Thanks for the pointer @ivogabe

@ivogabe
Copy link
Owner

ivogabe commented May 1, 2015

I'd advise everyone to use the new Visual Studio Code, which support typescript & gulp out of the box. It's also available for mac & linux.

For the normal Visual Studio users, this page from grunt-ts might be useful: How to disable the Visual Studio TypeScript build.

@ivogabe ivogabe closed this as completed May 1, 2015
@ghost
Copy link

ghost commented Jun 15, 2015

Use the command line, conemu, cygwin ex: http://superuser.com/a/900232/436535

IDE integration only leads to frustration and missed opportunity. Use gulp-watch and some proper terminal configuration and bliss

@netdragonboberb
Copy link

netdragonboberb commented Nov 11, 2016

See also .csproj option (I think it also works in .njsproj files) from microsoft/TypeScript#2326 to stick in PropertyGroup AFTER the Microsoft.TypeScript.targets as follows:

  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" Condition="False" />
      <PropertyGroup>
        <TypeScriptCompileBlocked>True</TypeScriptCompileBlocked>
        <TypescriptCompileOnSaveEnabled>False</TypescriptCompileOnSaveEnabled>
    </PropertyGroup>

See also: https://shauntm.com/notes/entries/231

@meziantou
Copy link

I wrote a guide to replace the default compilation of TypeScript files in Visual Studio by Gulp: https://www.meziantou.net/2017/10/23/compiling-typescript-using-gulp-in-visual-studio

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants