D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 22747 - VS 2022 Could not load file or assembly 'Microsoft.Build.CPPTasks.Common, Version=17.1.0.0'
Summary: VS 2022 Could not load file or assembly 'Microsoft.Build.CPPTasks.Common, Ver...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: visuald (show other issues)
Version: D2
Hardware: x86_64 Windows
: P1 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-02-08 12:42 UTC by Richard Manthorpe
Modified: 2022-04-03 12:21 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Richard Manthorpe 2022-02-08 12:42:46 UTC
C:\Program Files (x86)\VisualD\msbuild\dcompile.targets(192,5): error MSB4062: The "dbuild.CompileD" task could not be loaded from the assembly C:\Program Files (x86)\VisualD\msbuild\dbuild.17.0.dll. Could not load file or assembly 'Microsoft.Build.CPPTasks.Common, Version=17.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> 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.

I'm running
Visual D v1.2.0
Visual Studio 17.0.5+32112.339

The CPPTasks DLL version shipped with VS is
Microsoft.Build.CPPTasks.Common, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a


I believe the problem here is that MSBuild no longer comes with binding redirects for Microsoft.Build.CPPTasks.Common. The current  version of Visual Studio (17.0), and crucially the version of Microsoft.Build.CPPTasks.Common.dll it ships with (17.0.0.0) do not match the version that Visual D was built against (17.1.0.0).

As I understand it, since MSBuild no longer includes binding redirects for this DLL VS now includes a new DLL (Microsoft.Build.CPPTasks.Common.Base.dll) with a version number that will remain stable across minor versions and only be updated for major releases. I think if you target this DLL both in dbuild.csproj and with CPPTasksPath in dbuild.targets it should work across all Visual Studio 2022 minor versions.
Comment 1 Rainer Schuetze 2022-02-11 17:34:50 UTC
Thanks for the reminder. Unfortunately the *Base.Dll doesn't seem to work, so I created two versions of dbuild for 17.0 and 17.1.

I cannot really verify as I cannot install both versions at the same time, so can you try it with https://gist.github.com/rainers/6cdf73b48837defb9f88/raw/adb40bdac26c07b57ebce92627563aff2b7b5f75/VisualD-v1.2.1-beta1.exe ?
Comment 2 Richard Manthorpe 2022-02-12 00:10:14 UTC
I tested it out on 17.0 and it worked perfectly, thanks!
Comment 3 Rainer Schuetze 2022-04-03 12:21:37 UTC
Fix finally released in https://github.com/dlang/visuald/releases/tag/v1.3.0-rc1