Reputation: 131
While trying to build a newly setup project using npm run build
, I am facing the below mentioned error in Powershell on Windows, however, it runs fine inside the Visual Studio integrated Powershell.
Error:
C:..\src\packages\Microsoft.Portal.Tools.5.0.303.3330\build\TypeScript\tools\Microsoft.TypeScript.targets(219,5): error MSB406 2: The "TypeScript.Tasks.CheckFileSystemCaseSensitive" task could not be loaded from the assembly C:..\src\packages\Microsoft.Portal.Tools.5.0.303.3330\build\TypeScript\build..\tools\net45\TypeScript.Tasks.dll. Could not load file or assembly 'Microsoft.Build.Utilities.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask[C:..\src\Default\Extension\Extension.csproj]
Upvotes: 0
Views: 571
Reputation: 1415
When you are running it from VS integrated PowerShell it uses correct version of MSBuild but may not find latest one when running from Windows PowerShell.
If you want to use the Latest available MSBuild on any machine; Visual Studio(VS2017 and above) comes with utility called vswhere which can be used to find out latest MSBuild version
You can manually update the PATH in environment variable or write a PS script to find the latest MSBuild version using below code snippet
$vsWherePath = ${Env:ProgramFiles(x86)} + '\Microsoft Visual Studio\Installer\vswhere.exe'
$detectedMSBuildPath = & $vsWherePath -latest -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe;
Write-Host $detectedMSBuildPath
& $detectedMSBuildPath -version #Command to execute msbuild
This way, even if your MSBuild version is updated; it will always find and use latest MSBuild on machine.
Upvotes: 1
Reputation: 23808
Getting error MSB406 “TypeScript.Tasks.CheckFileSystemCaseSensitive” in Windows Powershell but the same build works in VS Powershell
Since you built extension project successfully in vs powershell, I think you put a wrong MSBuild version in PATH system environment variables.
Instead, you should use C:\Program Files (x86)\Microsoft Visual Studio\2019\xxx\MSBuild\Current\Bin\MSBuild.exe
.
Solution
1) check the PATH and remove the previous wrong MSBuild path.
2) then input C:\Program Files (x86)\Microsoft Visual Studio\2019\xxx\MSBuild\Current\Bin
in PATH, restart Windows Powershell to build again.
Upvotes: 1