If you include typescript in your project like Scott Hanselman describes here, you end up with this in your csproj file:

<Target Name="BeforeBuild">
<Exec Command="&quot;$(PROGRAMFILES)Microsoft
      SDKsTypeScript.8.0.0tsc&quot; @(TypeScriptCompile
      ->'&quot;%(fullpath)&quot;', ' ')" />
</Target>

Which is fine and works… until you try to build this with TFS build.
Your build will likely with an error like this:

C:Builds2ITQZorin DevSourceszorinITQ.Zorin.Web
ITQ.Zorin.Web.csproj (344): The command
“”C:Program Files (x86)Microsoft SDKsTypeScript.8.0.0tsc”
“C:Builds2ITQZorin DevSourceszorinITQ.Zorin.WebScripts
TypeScriptNotifications.ts”
“C:Builds2ITQZorin DevSourceszorinITQ.Zorin.WebScripts
TypeScriptVM.ts”” exited with code 1.

This is because the .js files are readonly and the typescript
compiler tries to overwrite them.
Simply changing the readonly attribute with Attrib –b in the
BeforeBuild event will solve this problem:

  <Target Name="BeforeBuild">
    <Exec Command="attrib -r &quot;$(MSBuildProjectDirectory)
        Scriptstypescript*.js&quot;" />
    <Exec Command="&quot;$(PROGRAMFILES)Microsoft
       SDKsTypeScript.8.0.0tsc&quot; @(TypeScriptCompile
          ->'&quot;%(fullpath)&quot;', ' ')" />
  </Target>
Flores Eken

Author Flores Eken

I’m passionate about technology in general and particularly about software development and automation. Specializing in Infrastructure automation and Microsoft .NET, I can handle the entire process, from installing a Team Foundation Server to the smallest programming detail. Always innovating and on the cutting edge.

More posts by Flores Eken
18 October 2012

Leave a Reply