4

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.

3
  • Hi @Gent, I was wondering if you got it to work? Please let me know if you still have a problem with this. Commented Oct 2, 2014 at 7:36
  • @MrMathos I got it figured out, however the typescript installation was present on the build server so it ended up being a different issue than detailed in your answer. Thanks for your time and help. Commented Oct 3, 2014 at 18:51
  • No problem, glad you found it! Commented Oct 7, 2014 at 12:33

4 Answers 4

7

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.

Sign up to request clarification or add additional context in comments.

4 Comments

let me ask you - when you added this it actually puts the files on the target server? I'm in a similar situation where I got my whole deal working using publish locally, but when I actually ran the same .csproj setup on the actual build server by queueing a build, it didn't work.
Yep, it works through msbuild on jenkins and via octopus deploy as well, as long as its added to the csproj itself
This is so weird, why would mine not copy the files to the target server? It doesn't put them in the _publishedwebsites folder, nor the target server itself. I basically just used what you have above. Was there anything else?
Have you verified that the js files exist in place after build? For example if you had "Scripts/SomeLibrary.ts" you find a "Scripts/SomeLibrary.js"
5

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!

1 Comment

Thank you! This should be marked as the answer. The answer you've linked to investigated and found the root of the problem coming from a poor decision by Microsoft in their Publish task target file.
0

TypeScript is probably not installed on your build server. To install it, copy your TypeScript folder from c:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\ to the same folder on your build server (where v12 is the version of your Visual Studio).

The Visual Studio version on your build server can be different however. In my situation, the version on my development machine is v12, while the build server uses v11. I found that out by adding the following to the [WebProjectName].csproj file:

<Target Name="PrintVisualStudioInfo">
    <Message Text="VisualStudioVersion: '$(VisualStudioVersion)'" Importance="High" />
</Target>
<PropertyGroup>
    <CompileDependsOn>
        PrintVisualStudioInfo;
        $(CompileDependsOn)
    </CompileDependsOn>
</PropertyGroup>

Be sure you put it after the last <Import /> element. Now when you look at the output of your build on the build server, you should see 'VisualStudioVersion: xx' somewhere.

Copy the TypeScript folder to the correct version folder on the build server.

Comments

0

Just adding in case it helps people.
We had this issue recently and it was fixed by adding /p:VisualStudioVersion=12.0 to the BAT file :

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe FullBuild.proj /p:VisualStudioVersion=12.0 /t:createRelease /p:ReleaseNumber=5.22.0

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.