TypeScript: Could not file 'should_not_exist.file'

We just update some applications using Visual Studio .csproj files and Typescript to 2.7.1 (strict).

The process went smoth, fixing the definitely assignment of class fields, but the CI system fails with the following message:

Copying file should_not_exist.file to obj\x64\To-Test\Package\PackageTmp failed. Could not find file 'should_not_exist.file'

The project file is very similar to: https://github.com/signumsoftware/southwind/blob/master/Southwind.React/Southwind.React.csproj

This file contains two custom blocks:

SignumTSGenerator

Custom MSBuild task that generates TS code from C#, commenting it out does not make any difference so I think is ok.

 <UsingTask TaskName="SignumTSGenerator" AssemblyFile="..\Framework\Signum.TSGenerator\Binaries\Signum.TSGenerator.dll" />
  <Target Name="GenerateSignumTS">
    <SignumTSGenerator References="@(ReferencePath)" Content="@(Content);@(None)" />
  </Target>
  <PropertyGroup>
    <CompileTypeScriptDependsOn>
      GenerateSignumTS;
      $(CompileTypeScriptDependsOn);
    </CompileTypeScriptDependsOn>
  </PropertyGroup>

WebPackBuild

This parts collects everithing in dist folder to the MSDeploy package. Commenting it out removes the problem (but of course the application doesn’t work).

 <PropertyGroup Condition="'$(Configuration)' != 'Debug'">
   <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
   <CompileDependsOn>
     $(CompileDependsOn);
     WebPackBuild;
   </CompileDependsOn>
 </PropertyGroup>
 <Target Name="WebPackBuild" DependsOnTargets="CompileTypeScript">
   <Exec Command="npm install" />
   <Exec Command="npm run build" />
 </Target>
 <PropertyGroup Condition="'$(Configuration)' != 'Debug'">
   <CopyAllFilesToSingleFolderForPackageDependsOn>
     $(CopyAllFilesToSingleFolderForPackageDependsOn);
     CollectWebpackOutput;
   </CopyAllFilesToSingleFolderForPackageDependsOn>
   <CopyAllFilesToSingleFolderForMsdeployDependsOn>
     $(CopyAllFilesToSingleFolderForMsdeployDependsOn);
     CollectWebpackOutput;
   </CopyAllFilesToSingleFolderForMsdeployDependsOn>
 </PropertyGroup>
 <Target Name="CollectWebpackOutput">
   <ItemGroup>
     <_CustomWebpackFiles Include="dist\**\*" />
     <FilesForPackagingFromProject Include="%(_CustomWebpackFiles.Identity)">
       <DestinationRelativePath>dist\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
     </FilesForPackagingFromProject>
   </ItemGroup>
   <Message Text="CollectWebpackOutput list: %(_CustomWebpackFiles.Identity)" />
 </Target>

Also, reverting the commits that updated to 2.7 (similar to https://github.com/signumsoftware/southwind/commit/d9c20f181f9512ef6c602de98c6f489a8c21b937#diff-b80350f6aff97bcc35c7aa3fe715a3b2) removes the problem.

I’ve compared a v=diag build of the solution with 2.6 and 2.7.

The files are quite big, but while the 2.6 version makes no reference to should_not_exist.file, the new one does many times. Here are the Search results:

        Line 357963: Added Item(s): GeneratedJavascript=should_not_exist.file
	Line 357967: Output file "should_not_exist.file" does not exist.
	Line 357973: Removed Item(s): GeneratedJavascript=should_not_exist.file
	Line 418646: Added Item(s): GeneratedJavascript=should_not_exist.file
	Line 418650: Output file "should_not_exist.file" does not exist.
	Line 418655: Removed Item(s): GeneratedJavascript=should_not_exist.file
	Line 476007: Added Item(s): GeneratedJavascript=should_not_exist.file
	Line 476015:   Task Parameter:Files=should_not_exist.file (TaskId:673)
	Line 476019:           should_not_exist.file
	Line 476020:                   OriginalItemSpec=should_not_exist.file
	Line 476021:                   TargetPath=should_not_exist.file (TaskId:673)
	Line 476025:         should_not_exist.file
	Line 476030:                 OriginalItemSpec=should_not_exist.file
	Line 476032:                 TargetPath=should_not_exist.file
	Line 476035:         should_not_exist.file
	Line 476036:                 OriginalItemSpec=should_not_exist.file
	Line 476037:                 TargetPath=should_not_exist.file
	Line 476038: Added Item(s): Content=should_not_exist.file
	Line 495027:           C:\Code\IntTec\IntTec.React\should_not_exist.file (TaskId:699)
	Line 495523:           C:\Code\IntTec\IntTec.React\should_not_exist.file (TaskId:699)
	Line 495726:   Task Parameter:Text=App\Calculation\Templates\CalculationDocumentsPage.tsx;App\Calculation\Templates\VehicleDiagram.css;App\Calculation\Templates\VehicleDiagram.svg;App\Calculation\ThreeCar\Assets\Shadow.png;App\Calculation\ThreeCar\Assets\Sky.jpg;App\DocumentViewer\images\arrow.png;App\DocumentViewer\images\circle.png;App\DocumentViewer\images\rect.png;App\DocumentViewer\Lightbox.css;App\DocumentViewer\Lightbox.tsx;App\DocumentViewer\Portal.tsx;App\Gateway\DAT\SilverDatIntegration\siteSilverDat.css;App\siteVehicle.css;App\site.css;App\Mapping\MappingTable.css;App\ImportGlasmatic\IntTec.Entities.ImportGlasmatic.t4s;App\Gateway\Autoonline\IntTec.Entities.Gateway.Autoonline.t4s;App\static\CeLogoBrand.svg;App\static\synapses.png;App\VehicleSearch\AwesomeSearch.css;App\VehicleSearch\logo_ce.svg;App\vendors.js;favicon.ico;Global.asax;App\VehicleSearch\MyTest.html;package.json;App\ImportAudatex\IntTec.Entities.ImportAudatex.t4s;App\ApiModels\IntTec.Entities.ApiModels.t4s;App\Calculation\IntTec...
	Line 495727:   App\Calculation\Templates\CalculationDocumentsPage.tsx;App\Calculation\Templates\VehicleDiagram.css;App\Calculation\Templates\VehicleDiagram.svg;App\Calculation\ThreeCar\Assets\Shadow.png;App\Calculation\ThreeCar\Assets\Sky.jpg;App\DocumentViewer\images\arrow.png;App\DocumentViewer\images\circle.png;App\DocumentViewer\images\rect.png;App\DocumentViewer\Lightbox.css;App\DocumentViewer\Lightbox.tsx;App\DocumentViewer\Portal.tsx;App\Gateway\DAT\SilverDatIntegration\siteSilverDat.css;App\siteVehicle.css;App\site.css;App\Mapping\MappingTable.css;App\ImportGlasmatic\IntTec.Entities.ImportGlasmatic.t4s;App\Gateway\Autoonline\IntTec.Entities.Gateway.Autoonline.t4s;App\static\CeLogoBrand.svg;App\static\synapses.png;App\VehicleSearch\AwesomeSearch.css;App\VehicleSearch\logo_ce.svg;App\vendors.js;favicon.ico;Global.asax;App\VehicleSearch\MyTest.html;package.json;App\ImportAudatex\IntTec.Entities.ImportAudatex.t4s;App\ApiModels\IntTec.Entities.ApiModels.t4s;App\Calculation\IntTec.Entities.Calculatio...
	Line 496196:         should_not_exist.file
	Line 496198:                 DestinationRelativePath=should_not_exist.file
	Line 499880:           should_not_exist.file
	Line 499885:                   OriginalItemSpec=should_not_exist.file
	Line 499887:                   TargetPath=should_not_exist.file
	Line 500249:           should_not_exist.file
	Line 500251:                   DestinationRelativePath=should_not_exist.file
	Line 503222:           should_not_exist.file
	Line 503227:                   OriginalItemSpec=should_not_exist.file
	Line 503229:                   TargetPath=should_not_exist.file
	Line 503591:           should_not_exist.file
	Line 503593:                   DestinationRelativePath=should_not_exist.file
	Line 506565:           should_not_exist.file
	Line 506570:                   OriginalItemSpec=should_not_exist.file
	Line 506572:                   TargetPath=should_not_exist.file
	Line 506934:           should_not_exist.file
	Line 506936:                   DestinationRelativePath=should_not_exist.file
	Line 510323:           should_not_exist.file
	Line 510328:                   OriginalItemSpec=should_not_exist.file
	Line 510330:                   TargetPath=should_not_exist.file
	Line 510686:           should_not_exist.file
	Line 510688:                   DestinationRelativePath=should_not_exist.file
	Line 514616:           should_not_exist.file
	Line 514621:                   OriginalItemSpec=should_not_exist.file
	Line 514623:                   TargetPath=should_not_exist.file
	Line 514972:           should_not_exist.file
	Line 514974:                   DestinationRelativePath=should_not_exist.file
	Line 517965:   Copying should_not_exist.file to obj\x64\To-Test\Package\PackageTmp. (TaskId:781)
	Line 517966: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\v15.0\Web\Microsoft.Web.Publishing.targets(2603,5): error : Copying file should_not_exist.file to obj\x64\To-Test\Package\PackageTmp failed. Could not find file 'should_not_exist.file'. [C:\Code\IntTec\IntTec.React\IntTec.React.csproj]
	Line 517966: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\v15.0\Web\Microsoft.Web.Publishing.targets(2603,5): error : Copying file should_not_exist.file to obj\x64\To-Test\Package\PackageTmp failed. Could not find file 'should_not_exist.file'. [C:\Code\IntTec\IntTec.React\IntTec.React.csproj]
	Line 517969:           should_not_exist.file
	Line 517974:                   OriginalItemSpec=should_not_exist.file
	Line 517976:                   TargetPath=should_not_exist.file
	Line 518325:           should_not_exist.file
	Line 518327:                   DestinationRelativePath=should_not_exist.file
	Line 673727:   C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\v15.0\Web\Microsoft.Web.Publishing.targets(2603,5): error : Copying file should_not_exist.file to obj\x64\To-Test\Package\PackageTmp failed. Could not find file 'should_not_exist.file'. [C:\Code\IntTec\IntTec.React\IntTec.React.csproj]
	Line 673727:   C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\v15.0\Web\Microsoft.Web.Publishing.targets(2603,5): error : Copying file should_not_exist.file to obj\x64\To-Test\Package\PackageTmp failed. Could not find file 'should_not_exist.file'. [C:\Code\IntTec\IntTec.React\IntTec.React.csproj]

Any idea what this files does, and why/how it could interact with MSDeploy / dist folder?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 3
  • Comments: 29 (11 by maintainers)

Commits related to this issue

Most upvoted comments

@olmobrutall Seems that we have a bug involving TypeScriptCompileBlocked. I apologize for the inconvenience this has caused you. I will fix this in a future version of the TS SDK, but for now, the culprit is line 310 of C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.7\build\Microsoft.TypeScript.targets. If you change it from

<GeneratedJavascript Condition="'@(GeneratedJavascript)' == ''" Include="should_not_exist.file" />

to

<GeneratedJavascript Condition="'@(GeneratedJavascript)' == '' AND '@(TypeScriptInputFiles)' != ''" Include="should_not_exist.file" />

then the dummy file will not be added to the list of files to copy.

Is there any update on this issue in regards to Visual Studio Team Services? The only way I can get the build to work in VSTS is if I download a local agent so it runs a correct TypeScript version.

Apparently VSTS updated their VS2017 Hosted environments to 2.7.1 yesterday, which causes this issue to appear for people using TypeScriptCompileBlocked in their csproj file. In case you’re here because of that, I was able to fix this by removing/commenting out this tag in the csproj file:

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets')" />

Update

I found out a better solution is to install the Microsoft.VisualStudio.MsBuild NuGet package v2.7.2. This updates the build targets to point to the nuget folder so we don’t rely on the environment’s TypeScript version. I didn’t realize Karl’s earlier comment about this was referring to a NuGet package.

Installing Microsoft.TypeScript.MSBuild (v2.7.2) got our VSTS builds working again. Probably better to be explicit with the TypeScript version to use than to let VSTS choose.

@uniqueiniquity I’d be glad to. My goal is to prevent the TypeScript Targets from being added to the .csproj project file since I am compiling TypeScript outside of MSBuild/Visual Studio.

EDIT: I should clarify my ultimate goal is to make sure that MSBuild/Visual Studio isn’t building my TypeScript, so if TypeScriptCompileBlocked is doing that maybe everything is working as expected.

Right now as soon as I add a TypeScript file to my .csproj project file and save the project file, Visual Studio will import the TypeScript targets. It would be great if there was someway I could signal to Visual Studio not to add those targets back on a TypeScript file add.

EDIT2: https://www.typescriptlang.org/docs/handbook/compiler-options-in-msbuild.html It looks like TypeScriptCompileBlocked should be preventing MSBuild from compiling and I have no evidence that it is not working. I thought the targets implied the compilation by MSBuild.

My apologies!

@j2jensen This seems to have worked. For anybody wanting the link to the NuGet (I found it in a comment you put somewhere else) https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild/

What I would like to know though, is there a way to just get MSBuild to not know about TypeScript at all. I am using WebPack to build JS, and my Publish includes the relevant created files. I don’t know MSBuild to touch my TypeScript files.

@trailmax Thanks for pointing that out; sorry for not being clearer.

In case more people run into this problem - updating your TS via npm is not enough. You actually need TypeScript SDK of version 2.7.2 (https://www.microsoft.com/en-us/download/confirmation.aspx?id=55258)

@karlromanowski Are you running a local agent? I was able to get it to work with a local agent but using a hosted agent makes the issue occur.

Gah, I had 2.7.2 installed on the machine, but 2.7.1 nuget package. Updated the nuget package, all is well.

glad I found this, this is serious problem as it effectively makes deployment from the IDE and from MSBUILD impossible. it’s not just an inconvenience…