问题
I am attempting to update a Visual Studio extension to be compatible for installation in Visual Studio 2017. I have followed the steps and notes in each of the following pages (and others I've searched):
- https://github.com/MicrosoftDocs/visualstudio-docs/blob/master/docs/extensibility/faq-2017.md#can-i-build-a-vsix-v3-with-visual-studio-2015
- http://www.visualstudioextensibility.com/2017/01/10/its-time-to-change-the-vsix-manifest-of-your-extension-to-v3-for-visual-studio-2017-compatibility/
In the end, the project (and extension) will build successfully locally, but it is failing on our TFS build server with the following error:
"d:\example\myproj\MyExtension\MyExtension.csproj" (Rebuild target) (25:7) ->
d:\example\myproj\packages\Microsoft.VisualStudio.Sdk.BuildTasks.14.0.14.9.23\build\Microsoft.VisualStudio.Sdk.BuildTasks.14.0.targets(16,5): error MSB4175: The task factory "CodeTaskFactory" could not be loaded from the assembly "C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Build.Tasks.v4.0.dll". Could not load file or assembly 'file:///C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Build.Tasks.v4.0.dll' or one of its dependencies. The system cannot find the file specified. [d:\example\myproj\MyExtension\MyExtension.csproj]
The assembly it's looking for is coming from the Microsoft.VisualStudio.Sdk.BuildTasks.14.0.targets file, and within the target (12.0) MSBuild directory, the file in question (Microsoft.Build.Tasks.v4.0.dll) doesn't exist. The local build resolves the file in question from the Reference Assembly folder on the system:
6> Dependency "Microsoft.Build.Tasks.v4.0, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
6> Resolved file path is "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Microsoft.Build.Tasks.v4.0.dll".
Has anyone else had any experience with this error to advise me as to why our build server is having this issue?
Additional note: I'm running Visual Studio 2015 (update 3) on both my local machine and on the build server in question.
回答1:
The assembly it's looking for is coming from the Microsoft.VisualStudio.Sdk.BuildTasks.14.0.targets file, and within the target (12.0) MSBuild directory, the file in question (Microsoft.Build.Tasks.v4.0.dll) doesn't exist.
According to the error message "C:\Program Files (x86)\MSBuild\12.0", it seems you are using the MSBuild 12.0 instead of MSBuild 14.0 on the build server. Make sure you are invoking the MSBuild from the path C:\Program Files (x86)\MSBuild\14.0\Bin
when you build with TFS. So, check if the MSBuild version is 14.0 or the MSBuild path is C:\Program Files (x86)\MSBuild\14.0\Bin
in TFS definition.
Besides, check if you have installed the .net framework 4.5.1 on the build server, if not, install it, then rebuild solution.
Hope this helps.
回答2:
If you have it working locally, just create a new project on TFS and transfer it, any missing packages will be re-stored when you open the project after you map it in you computer.
来源:https://stackoverflow.com/questions/53676961/trouble-upgrading-visual-studio-extension-to-include-visual-studio-2017-compatib