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:
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>
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).
```XML
$(CompileDependsOn);
WebPackBuild;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
CollectWebpackOutput;
$(CopyAllFilesToSingleFolderForMsdeployDependsOn);
CollectWebpackOutput;
<_CustomWebpackFiles Include="dist\**\*" />
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?
More Info:
If I update only package.json works.
The problem is updating <TypeScriptToolsVersion>2.7</TypeScriptToolsVersion>
the .csproj files.
@uniqueiniquity can you take a look? looks related to recent changes to the targets/tasks.
@olmobrutall Would you be willing to post or send me the whole v=diag
output?
It's a bit hard to tell from that set of lines what's actually happening.
In general, should_not_exist.file
is a dummy file name used (when TypeScriptCompileBlocked
is not set) to trigger a build when no build log file exists. So if it's not being removed from the GeneratedJavascript
item group properly for some reason, it is somehow getting propagated to the item list that determines what to copy from the dist
folder. Again, a full log would help me trace exactly how that's happening. A quick workaround would be to ensure should_not_exist.file
is removed from whatever item list is being processed on line 516965.
@uniqueiniquity I've managed to reproduce the issue in a very similar -but open source- application.
Clonning https://github.com/signumsoftware/southwind (master branch)
and runnning
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Msbuild.exe" Southwind.sln /p:Configuration=Release /p:Platform="Any CPU" /p:DeployOnBuild=true /p:PublishProfile=FolderProfile /p:VisualStudioVersion=15.0 /flp:v=diag
If you want to avoid the hassle the full log is here: https://1drv.ms/u/s!AiVD6FOsvtuPkHV5kvw9yqanZof_
There are about 12 csproj files and 3 of them have Typescript code:
The tsconfig.json files are using "noEmit": true,
while webpack.config overrides with
options: {
transpileOnly: true,
compilerOptions: {
"noEmit": false
}
}
This way I use MSBuild / VS for compile-time errors only, and webpack for javascript generation only.
If you look at the log, for Signum.React the file is added and removed:
Added Item(s): GeneratedJavascript=should_not_exist.file
Done building target "PreComputeCompileTypeScriptWithTSConfig" in project "Signum.React.csproj".: (TargetId:1310)
Target "CompileTypeScriptWithTSConfig: (TargetId:1311)" in file "C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.7\build\Microsoft.TypeScript.targets" from project "C:\Code\Southwind\Framework\Signum.React\Signum.React.csproj" (target "Compile" depends on it):
Building target "CompileTypeScriptWithTSConfig" completely.
Output file "should_not_exist.file" does not exist.
Using "CreateProperty" task from assembly "Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
Task "CreateProperty" (TaskId:814)
Task Parameter:Value=true (TaskId:814)
Output Property: CompileRan=true (TaskId:814)
Done executing task "CreateProperty". (TaskId:814)
Removed Item(s): GeneratedJavascript=should_not_exist.file
````
Same for **Signum.React.Extensions**:
Added Item(s): GeneratedJavascript=should_not_exist.file
Done building target "PreComputeCompileTypeScriptWithTSConfig" in project "Signum.React.Extensions.csproj".: (TargetId:1392)
Target "CompileTypeScriptWithTSConfig: (TargetId:1393)" in file "C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.7\build\Microsoft.TypeScript.targets" from project "C:\Code\Southwind\Extensions\Signum.React.Extensions\Signum.React.Extensions.csproj" (target "Compile" depends on it):
Building target "CompileTypeScriptWithTSConfig" completely.
Output file "should_not_exist.file" does not exist.
Task "CreateProperty" (TaskId:871)
Task Parameter:Value=true (TaskId:871)
Output Property: CompileRan=true (TaskId:871)
Done executing task "CreateProperty". (TaskId:871)
Removed Item(s): GeneratedJavascript=should_not_exist.file
But something different happens for **Soutnwind.React**:
Added Item(s): GeneratedJavascript=should_not_exist.file
Done building target "PreComputeCompileTypeScriptWithTSConfig" in project "Southwind.React.csproj".: (TargetId:1474)
Target "CompileTypeScriptWithTSConfig: (TargetId:1475)" in file "C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.7\build\Microsoft.TypeScript.targets" from project "C:\Code\Southwind\Southwind.React\Southwind.React.csproj" (target "Compile" depends on it):
Skipping target "CompileTypeScriptWithTSConfig" because it has no inputs.
Though the target has declared its inputs, the input specification only references empty properties and/or empty item lists.
Done building target "CompileTypeScriptWithTSConfig" in project "Southwind.React.csproj".: (TargetId:1475)
Target "GetTypeScriptOutputForPublishing: (TargetId:1476)" in file "C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.7\build\Microsoft.TypeScript.targets" from project "C:\Code\Southwind\Southwind.React\Southwind.React.csproj" (target "Compile" depends on it):
Task "AssignTargetPath" (TaskId:924)
Task Parameter:Files=should_not_exist.file (TaskId:924)
Task Parameter:RootFolder=C:\Code\Southwind\Southwind.React (TaskId:924)
Output Item(s):
GeneratedJavascriptWithTargetPath=
should_not_exist.file
OriginalItemSpec=should_not_exist.file
TargetPath=should_not_exist.file (TaskId:924)
Done executing task "AssignTargetPath". (TaskId:924)
Added Item(s):
FilesForPackagingFromProject=
should_not_exist.file
Category=Run
DestinationRelativePath=
Exclude=False
FromTarget=Unknown
OriginalItemSpec=should_not_exist.file
ProjectFileType=Default
TargetPath=should_not_exist.file
Added Item(s):
ContentWithTargetPath=
should_not_exist.file
OriginalItemSpec=should_not_exist.file
TargetPath=should_not_exist.file
Added Item(s): Content=should_not_exist.file
```
Looks like the file is not removed from the list.
I had this exact issue 6 days ago and nothing what I tried seemed to fix it (This thread is the only relevant google search result for should_not_exist.file
, there were no results before.). In the end, I managed to get rid of the error by repairing Visual Studio from the installer.
Note: I'm using Visual Studio 2015
I have the same problem after updating my visual studio typescript version to 2.7.1.
@olmobrutall seems like I don't have access for the one drive link. I'll clone the repo and investigate that way.
@uniqueiniquity the problem was with the last underscore in the link https://1drv.ms/u/s!AiVD6FOsvtuPkHV5kvw9yqanZof_
@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.
No worries.
Do you see possible that a TS 2.7.2 comes before 2.8? There are some developers involved and I had a bad experience doing custom hacks that then have to be roll-baked in every computer (https://github.com/Microsoft/TypeScript/issues/19406).
This change is planned for 2.7.2, should be out in a week or so.
Typescript team rocks :)
For those following along and fixing this before 2.7.2, the offending line might be 386, depending on whether or not your project has a TSConfig. Both lines will be fixed in 2.7.2.
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...
Still seeing this error with 2.7.2. Attaching build log...
@wldkrd1 The build log seems to say you are still using 2.7.1 (line 2455, for example).
Gah, I had 2.7.2 installed on the machine, but 2.7.1 nuget package. Updated the nuget package, all is well.
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.
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.
@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.
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)
@trailmax Thanks for pointing that out; sorry for not being clearer.
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')" />
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.
@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.
@Thorocaine, I believe that using @j2jensen's first suggestion will have the result you want, though in ASP.NET Core and NodeJS projects, this line is implicitly included.
Along with @Thorocaine I would like to know if there is a way to avoid the TypeScript targets from getting added to my .csproj file. I thought TypeScriptCompileBlocked would do it but I guess not.
@MKuenzi I guess my question to you is what do you wish TypeScriptCompileBlocked
was doing that it's not? In scenarios like ASP.NET Core, the TypeScript targets are always imported implicitly, so if there's something that the setting is not blocking, we'd certainly like it to work in those projects as well.
@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!
No worries, glad that everything is resolved! Let me know if you have any more questions.
Most helpful comment
@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
to
then the dummy file will not be added to the list of files to copy.