Skip to content

Major - Microsoft.TypeScript.MSBuild not working on Ubuntu when path to TSJavascriptFile contains spaces #33078

@nkosi23

Description

@nkosi23

TypeScript Tools Version:

3.6.0-beta
By the way why is this the output of tsc.js while I installed the latest stable version of the NuGet package (3.6.0), is it normal that a beta compiler is in the package? If so, shouldn't Microsoft.TypeScript.MSBuild-3.6.0 be marked as beta in NuGet?

Search Terms:
MSBuild

Expected behavior:

I am developping on Ubuntu using barebone emacs and mono. The project also uses C# so I leverage MSBuild (which I also quite enjoy as a build system). The csproj file is pretty much handcrafted, and I was able to build my project just fine for many years. This is a mature project, so I know that the problem is isolated to typescript.

I have followed the instructions mentioned on this page :
https://www.typescriptlang.org/docs/handbook/integrating-with-build-tools.html#msbuild

And I have of course adjusted the path to the files to match the path to the files installed by the NuGet package. I am expecting the project to build properly and typescript files to be compiled.

Actual behavior:

Unfortunately, when trying to build my project, I get an error saying that nodejs exited with error code 1. By increasing the verbosity of msbuild to see nodejs' call stack, I can see that nodejs crashes at the bootstrapping stage at

Function.Module._resolveFileName (module.js:547:15)

which means that the typescript file is not found. In msbuild's log in diagnotic mode, I have noticed that the path to tsc.js passed as a parameter to nodejs is not put within quotes while (for example) the path to the typescript files to compile are passed within quotes.

I have been able to confirm that this is indeed the problem as by invoking /usr/bin/nodejs directly in the shell I get the exact same error with the same call stack, while by putting the path within quotes tsc.js is properly executed.

I tried to naively patch Microsoft.Typescript.Targets to put single quotes around the TSJavascriptFile parameter of the VsTsc command at line 543 (in the definition of the Target CompileTypeScript - I do not use tsconfig files but TypeScriptCompile items in my csproj file so this is the target used), I tried to do that, but the path is totally messed up when I do so.

Turning TSJavascriptFile="$(TSJavascriptFile)" into TSJavascriptFile="'$(TSJavascriptFile)'" (single quotes added) and similar variants, turns for example

/dir1/dir2/my path with space

into

/dir1/dir2/my path with space"/dir1/dir2/my path with space"

when nodejs is invoked. So I guess the change may need to be done in TypeScript.Tasks.dll, but I am just guessing. I am targeting net45 and running on mono.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions