Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSBuild output missing javascript files compiled by Typescript

We use MSBuild on our CI server to compile our WebApp, however the build omits the JavaScript files built by TypeScript from the output of the build.

I would expect the output to contain the JavaScript and not the Typescript, however neither are in the output at the expected locations.

How can I include the JavaScript files without having to have them all in my solution? The TypeScript team seems to think this is bad, but I would rather not have duplicates of all the files in my solution either.

like image 824
Gent Avatar asked Dec 15 '22 20:12

Gent


2 Answers

The problem was due to using MSBuild instead of the "Publish" on the build server it seems. I added an AfterBuild target to content include all of the JS files to the build output.

<Target Name="AfterBuild">
   <ItemGroup>
      <Content Include="**\*.js" />
   </ItemGroup>
</Target>

Although this is not ideal, it allows the js files not to show in the solution when using visual studio and the files end up in the build output.

like image 169
Gent Avatar answered Jan 07 '23 11:01

Gent


I tried many solutions from the web including the <Content Include="**\*.js" />, but nothing worked. I'm using MSBuild on my local dev box and typescript is installed and targets available in C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\TypeScript.

It turns out my "old" MSBuild runner for web app csproj files is obsolete. I was doing this:

MSBuild.exe my.csproj /Target:ResolveReferences;_CopyWebApplication /property:WebProjectOutputDir=myfolder;OutDir=myfolder\bin;Configuration=Debug 

but thanks to this post I need to use UseWPP_CopyWebApplication instead of the legacy _CopyWebApplication:

MSBuild.exe /t:Rebuild "/p:WebProjectOutputDir=myfolder;OutDir=myfolder\bin;Configuration=Debug;UseWPP_CopyWebApplication=True;PipelineDependsOnBuild=False" my.csproj

Now without any editing of the csproj file, all my TypeScript is included!

like image 40
thinkOfaNumber Avatar answered Jan 07 '23 11:01

thinkOfaNumber