mikefourie-zz / MSBuildExtensionPack

MIT License
366 stars 104 forks source link

Cannot get 4.0.15 working with VS 2017 #76

Open aphilpotts opened 6 years ago

aphilpotts commented 6 years ago

The default installation location for 4.0.15 seems to be C:\Program Files (x86)\MSBuildExtensionPack\4.0

If I use that and try to get the tasks from my project file like this:

I get this error, see the way Visual Studio wants to use it's private copy of MsBuildExtensionPack


Microsoft Visual Studio

The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\MsBuildExtensionPack\4.0\MSBuild.ExtensionPack.tasks" was not found. Also, tried to find "MsBuildExtensionPack\4.0\MSBuild.ExtensionPack.tasks" in the fallback search path(s) for $(MSBuildExtensionsPath) - "C:\Program Files (x86)\MSBuild" . These search paths are defined in "C:\Users\aphilpotts\AppData\Local\Microsoft\VisualStudio\15.0_de9a5e6f\devenv.exe.config". Confirm that the path in the declaration is correct, and that the file exists on disk in one of the search paths. C:\dev\ink\working\logical ink\server\database2\LogicalInk.sqlproj

OK

To try to remedy this I COPIED the install to C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\MsBuildExtensionPack and it got further, but then fails when running the Task, like this:

C:\dev\ink\working\logical ink\server\database2\LogicalInk.sqlproj(216,7): Error: MSB4062: The "MSBuild.ExtensionPack.FileSystem.File" task could not be loaded from the assembly C:\Program Files (x86)\MSBuildExtensionPack\4.0\MSBuild.ExtensionPack.dll. Could not load file or assembly 'file:///C:\Program Files (x86)\MSBuildExtensionPack\4.0\MSBuild.ExtensionPack.dll' 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.

any ideas?

This is how I run the task

drwharris commented 6 years ago

So we use Extension Pack in our msbuild files and the way we have worked around this is firstly to use the NuGet package and then in the build xml file reference the targets as such:

<Import Project=".\packages\MSBuild.Extension.Pack.1.9.1\build\net40\MSBuild.Extension.Pack.targets"/>

HTH

Andrew

RobCoder commented 6 years ago

You have to install to the default install dir (MsBuildExtensionPack, not MSBuild/ExtensionPack). You can adjust the import statements in your build files to look like this to compensate:

<Import Condition="Exists('$(MSBuildExtensionsPath)\ExtensionPack\4.0\MSBuild.ExtensionPack.tasks')" Project="$(MSBuildExtensionsPath)\ExtensionPack\4.0\MSBuild.ExtensionPack.tasks" />
<Import Condition="Exists('$(MSBuildExtensionsPath)\..\MSBuildExtensionPack\4.0\MSBuild.ExtensionPack.tasks')" Project="$(MSBuildExtensionsPath)\..\MSBuildExtensionPack\4.0\MSBuild.ExtensionPack.tasks" />

This will allow them to work with either version installed.