MSBuildTasks and NuGet - How to recover the MSBuild.Community.Tasks.dll file?

I have a project in which the NuGet package is installed under MSBuildTasks . It installs two files: MSBuild.Community.Tasks.targets and MSBuild.Community.Tasks.dll in the .build directory in the solutions directory. This link to the package is added to the packages.config file in this project directory, so when I create the project (and with the NuGet package recovery settings turned on), it will restore the package, which works great, because then I can distribute the source to another developers and build it on our build server without any missing files ...

However, the problem is that when NuGet restores the package, it does not restore these two files to the expected location, it was originally when I first installed it using the Install-Package MSBuildTasks , which was in $(SolutionDir)\.build . Instead, he installed it in the $(SolutionDir)\packages\MSBuildTasks.1.4.0.78\tools , so now if I want to include the MSBuild.Community.Tasks.targets file, I have to fully reference this path in my .csproj or another .targets file. This creates a problem, as the version number will undoubtedly change, requiring manual correction.

Is there a way to restore the MSBuildTasks.targets and .dll files to the original location $(SolutionDir)\.build , where is it installed first? The current restore behavior in the package directory, while it makes sense for other packages, seems to be an error for this particular package, because I will not know the version number of the directory that will be included in my other .targets or. Csproj files.

+5
source share
2 answers

Restore NuGet will only download files to the package directory. He will not make any other changes.

Looking at the MSBuildTasks NuGet package , the files added to $(SolutionDir)\.build are added by the PowerShell script. This PowerShell script will not run when restoring a NuGet package.

You must add $(SolutionDir)\.build to the version control repository.

+6
source

With newer versions 1.5+, the Nuget package does not install itself in the solution catalog; this worked for me though:

 <PropertyGroup> <MSBuildCommunityTasksPath>$(USERPROFILE)\.nuget\packages\msbuildtasks\1.5.0.235\tools</MSBuildCommunityTasksPath> </PropertyGroup> 

This is due to the addition of the version, but if someone knows how to remove the need to update the version on the way when updating the package, that would be awesome.

0
source

Source: https://habr.com/ru/post/1205297/


All Articles