Skip to content

Commit 5dc6059

Browse files
committed
Fixed issue #3
Added install.ps1 and uninstall.ps1 to automatically add BeforeBuild Target with NugetContentRestoreTask.
1 parent 75933aa commit 5dc6059

File tree

5 files changed

+45
-8
lines changed

5 files changed

+45
-8
lines changed

MSBuild.NugetContentRestore.nuspec

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@
22
<package>
33
<metadata>
44
<id>MSBuild.NugetContentRestore</id>
5-
<version>0.1.3</version>
5+
<version>0.1.4</version>
66
<authors>Francisco Lopez</authors>
77
<owners>Francisco Lopez</owners>
88
<projectUrl>https://github.com/panchilo/MSBuild.NugetContentRestore</projectUrl>
99
<licenseUrl>https://github.com/panchilo/MSBuild.NugetContentRestore#license</licenseUrl>
1010
<requireLicenseAcceptance>false</requireLicenseAcceptance>
1111
<description>MSBuild task to restore Nuget content files to project folder</description>
12-
<releaseNotes>Added ignore file pattern support for *.pp</releaseNotes>
12+
<releaseNotes>Added install.ps1 and uninstall.ps1 to automatically add BeforeBuild Target with NugetContentRestoreTask.</releaseNotes>
1313
<copyright>Copyright 2014, Francisco Lopez</copyright>
1414
<tags>nuget content restore msbuild task</tags>
1515
</metadata>
1616
<files>
1717
<file src="Output\MSBuild.NugetContentRestore.dll" target="build\net40" />
1818
<file src="MSBuild.NugetContentRestore.targets" target="build\net40" />
19+
<file src="tools\" target="tools" />
1920
<file src="readme.txt" target="" />
2021
</files>
2122
</package>

build.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
nuget pack MSBuild.NugetContentRestore.nuspec
2+
copy MSBuild.NugetContentRestore.0.1.4.nupkg C:\nuget\repo /Y

readme.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ MSBuild.NugetContentRestore README
33

44
Congratulations! MSBuild.NugetContentRestore is now installed to your project.
55
A reference to NugetContentRestoreTask has been added to your project.
6-
The only remaining step is to use it. Here is an example of how (and when) I use it.
7-
Edit your project file so it looks something like this:
6+
Starting on version v.0.1.4, MSBuild.NugetContentRestore also took care of
7+
creating 'BeforeBuild' Target with NugetContentRestoreTask in it.
88

9-
<Target Name="BeforeBuild">
10-
<NugetContentRestoreTask SolutionDir="$(SolutionDir)" ProjectDir="$(ProjectDir)" />
11-
</Target>
9+
All NuGet Packages Content Folders will be copied to your project folder right
10+
before is built.
1211

13-
All NuGet Packages Content Folders will be copied to your project folder right before is built.
12+
Enjoy!

tools/install.ps1

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
param($installPath, $toolsPath, $package, $project)
2+
3+
$projectPath = (Get-Project).FullName
4+
$buildProject = @([Microsoft.Build.Evaluation.ProjectCollection]::GlobalProjectCollection.GetLoadedProjects($projectPath))[0]
5+
6+
$target = $buildProject.Xml.Targets | Where { $_.Name -eq "BeforeBuild" } | Select -First 1
7+
If ($target -eq $Null) {
8+
$target = $buildProject.Xml.AddTarget("BeforeBuild")
9+
}
10+
11+
$task = $target.Tasks | Where { $_.Name -eq "NugetContentRestoreTask" } | Select -First 1
12+
If ($task -eq $Null) {
13+
$task = $target.AddTask("NugetContentRestoreTask")
14+
$task.SetParameter("SolutionDir", "`$(SolutionDir)")
15+
$task.SetParameter("ProjectDir", "`$(ProjectDir)")
16+
17+
$buildProject.Save()
18+
$project.Save()
19+
}

tools/uninstall.ps1

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
param($installPath, $toolsPath, $package, $project)
2+
3+
$projectPath = (Get-Project).FullName
4+
$buildProject = @([Microsoft.Build.Evaluation.ProjectCollection]::GlobalProjectCollection.GetLoadedProjects($projectPath))[0]
5+
6+
$target = $buildProject.Xml.Targets | Where { $_.Name -eq "BeforeBuild" } | Select -First 1
7+
If ($target -ne $Null) {
8+
$task = $target.Tasks | Where { $_.Name -eq "NugetContentRestoreTask" } | Select -First 1
9+
If ($task -ne $Null) {
10+
$target.RemoveChild($task)
11+
12+
$buildProject.Save()
13+
$project.Save()
14+
}
15+
}
16+

0 commit comments

Comments
 (0)