1

I'd like to do the inverse of this question/answer: How to include TypeScript files when publishing?

The thing is that I'm trying to publish an ASP.NET MVC 5 Project. Unfortunately the dreaded Visual Studio and the hungry Jack Typescript interpreter ignores any tsconfig.json file and decides to go deep down and look for any .ts file that is not accompanied by a .js. I have lots of npm packages nested down and some of them have uncompiled typescript files.

Funny thing is, that they are not included in the project (not even an exclamation mark). (I even checked for the .csproj and no files were found).

Is this a bug? How can I prevent this from happening? Using VS 2015.2 (Update 2).

halfer
  • 19,824
  • 17
  • 99
  • 186
Jose A
  • 10,053
  • 11
  • 75
  • 108

1 Answers1

1

I had a very similar issue. Publish kept failing because it couldn't find foo.js as it wasn't in the same directory as my ts/tsconfig files, even though outDir was set to another location. I don't know if it is a bug or not but I couldn't figure it out using the tsconfig. Instead, I was able to get things working by using the inbuilt TypeScript Build settings instead.

  1. First, I deleted all tsconfig files from my project (I made sure I kept a backup just in case). The TypeScript Build was originally greyed out because I had the tsconfig files in my project.
  2. Next, I created a new folder directly under Scripts to save the js files into.
  3. I then went to Project Properties and selected the TypeScript Build tab. Under Output, I checked the Redirect JavaScript output to directory and browsed to the newly created folder. I repeated this for all build configurations.
  4. Finally, I included the new folder in my project and then built. Folders and files which aren't included in the project can be seen as a ghost icon in the Solution Explorer if you have Show All Files icon selected. I think that if you have multiple TypeScript projects with their own tsconfigs, the file structures are replicated under the chosen output directory but I haven't tested it in many cases so I'm not certain.

Obviously I had to redirect my script bundles to the newly created js structure.

When I first followed this process, I got a few build errors mainly due to my own daft mistakes in my TypeScript code which I'd set the tsconfig to conveniently ignore. Another error was multiple references for objects, which I managed to fix by deleting the definitions files and making sure that the Generate declaration files option was unchecked in Typescript Build. Once I fixed those issues though, I was able to publish without that annoying error - happy days!

Code_Frank
  • 381
  • 1
  • 6
  • Thanks. I will definitely see it forward. I ended up creating the placeholder typescript files. Thanks for point #4, because that's the same situation I'm in. I think I'll end up excluding any typescript files from the main project and only point it to .js files as you suggested. That way Visual Stuido will not block me – Jose A Jun 15 '16 at 15:25