diff --git a/.gitignore b/.gitignore
index f38431f..30b7784 100644
--- a/.gitignore
+++ b/.gitignore
@@ -63,3 +63,5 @@ source/Samples/.octopack
_ReSharper*
source/Samples/packages
!source/build
+_NCrunch_*/
+*.v3.ncrunch*
diff --git a/source/OctoPack.Tasks/OctoPack.Tasks.csproj b/source/OctoPack.Tasks/OctoPack.Tasks.csproj
index 0d648de..79334a4 100644
--- a/source/OctoPack.Tasks/OctoPack.Tasks.csproj
+++ b/source/OctoPack.Tasks/OctoPack.Tasks.csproj
@@ -64,26 +64,7 @@
-
-
- OctoPack.targets
- PreserveNewest
- Designer
-
-
-
-
-
- NuGet.exe
- Always
-
-
-
- dir
-xcopy * ..\..\..\Samples\.octopack\ /Y
-copy nuget.exe ..\..\..\Samples\.nuget\
-
@@ -91,7 +72,7 @@ copy nuget.exe ..\..\..\Samples\.nuget\
-
+
+
+ $(BuildDependsOn);
+ OctoPackSlnCopyItemsForTests
+
+
+
+
+ $(MSBuildThisFileDirectory)\..\build\
+ $(MSBuildThisFileDirectory)\..\Samples\
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/source/OctoPack.Tests/Tasks/AssemblyExtensionsTests.cs b/source/OctoPack.Tests/Tasks/AssemblyExtensionsTests.cs
index a3d1d7c..f47b8b1 100644
--- a/source/OctoPack.Tests/Tasks/AssemblyExtensionsTests.cs
+++ b/source/OctoPack.Tests/Tasks/AssemblyExtensionsTests.cs
@@ -1,6 +1,7 @@
-using System.IO;
-using System.Reflection;
+using System.Reflection;
using NUnit.Framework;
+using GitVerAsm = OctoPack.Tests.SampleGitVersionAssembly;
+using NoGitVerAsm = OctoPack.Tests.NonGitVersionAssembly;
namespace OctoPack.Tests.Tasks
{
@@ -10,7 +11,7 @@ public class AssemblyExtensionsTests
[Test]
public void AssertAssemblyVersion_WhereNoGitVersionProperty_ReturnsNull()
{
- var assemblyPath = GetAssemblyFullPath("OctoPack.Tests.NonGitVersionAssembly");
+ var assemblyPath = Assembly.GetAssembly(typeof(NoGitVerAsm.ClassReferencingDependency)).FullLocalPath();
var gitversion = AssemblyExtensions.GetNuGetVersionFromGitVersionInformation(assemblyPath);
Assert.That(gitversion, Is.Null);
}
@@ -18,36 +19,17 @@ public void AssertAssemblyVersion_WhereNoGitVersionProperty_ReturnsNull()
[Test]
public void AssertAssemblyVersion_WhereDependentAssemblyOnlyInSource_GetsGitVersion()
{
- var assemblyPath = GetAssemblyFullPath("OctoPack.Tests.SampleGitVersionAssembly");
+ var assemblyPath = Assembly.GetAssembly(typeof(GitVerAsm.ClassReferencingDependency)).FullLocalPath();
var gitversion = AssemblyExtensions.GetNuGetVersionFromGitVersionInformation(assemblyPath);
Assert.That(gitversion, Is.EqualTo("1.1.1-tests"));
}
[Test]
- public void AssertAssembly_WhereDependentAssemblyNotEventInSource_GetsGitVersion()
+ public void AssertAssembly_WhereDependentAssemblyNotEvenInSource_GetsGitVersion()
{
- var assemblyPath = GetAssemblyFullExceptionPath("OctoPack.Tests.SampleGitVersionAssembly");
+ var assemblyPath = Assembly.GetAssembly(typeof(GitVerAsm.ClassReferencingDependency)).FullLocalPath();
var gitversion = AssemblyExtensions.GetNuGetVersionFromGitVersionInformation(assemblyPath);
Assert.That(gitversion, Is.EqualTo("1.1.1-tests"));
}
-
- private string GetAsseblyLocation(string name)
- {
- var currentAssemblyPath = Assembly.GetExecutingAssembly().FullLocalPath();
- var configuration = new FileInfo(currentAssemblyPath).Directory.Name;
- return Path.Combine(currentAssemblyPath, "..", "..", "..", "..", name, "bin", configuration);
- }
-
- private string GetAssemblyFullPath(string name)
- {
- var assemblyPath = Path.Combine(GetAsseblyLocation(name), $"{name}.dll");
- return new FileInfo(assemblyPath).FullName;
- }
-
- private string GetAssemblyFullExceptionPath(string name)
- {
- var assemblyPath = Path.Combine(GetAsseblyLocation(name), "StandAloneDll", $"{ name}.dll");
- return new FileInfo(assemblyPath).FullName;
- }
}
}
\ No newline at end of file
diff --git a/source/OctoPack.Tests/packages.config b/source/OctoPack.Tests/packages.config
index 724079a..c43f005 100644
--- a/source/OctoPack.Tests/packages.config
+++ b/source/OctoPack.Tests/packages.config
@@ -11,4 +11,5 @@
-
\ No newline at end of file
+
+
diff --git a/source/OctoPack.sln b/source/OctoPack.sln
index 1af2e04..a79c5fb 100644
--- a/source/OctoPack.sln
+++ b/source/OctoPack.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.26730.12
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.30320.27
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OctoPack.Tasks", "OctoPack.Tasks\OctoPack.Tasks.csproj", "{BEF74811-0C8D-45D4-B9DE-232795A3A84D}"
EndProject
@@ -26,6 +26,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OctoPack.Tests.SampleDllDependency", "OctoPack.Tests.SampleDllDependency\OctoPack.Tests.SampleDllDependency.csproj", "{58CAD859-2241-4750-8A32-932166129F72}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OctoPack.Tests.SampleExeDependency", "OctoPack.Tests.SampleExeDependency\OctoPack.Tests.SampleExeDependency.csproj", "{5DCD7348-929B-42BE-A1CD-5DDA91C6477B}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -52,6 +54,10 @@ Global
{58CAD859-2241-4750-8A32-932166129F72}.Debug|Any CPU.Build.0 = Debug|Any CPU
{58CAD859-2241-4750-8A32-932166129F72}.Release|Any CPU.ActiveCfg = Release|Any CPU
{58CAD859-2241-4750-8A32-932166129F72}.Release|Any CPU.Build.0 = Release|Any CPU
+ {5DCD7348-929B-42BE-A1CD-5DDA91C6477B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5DCD7348-929B-42BE-A1CD-5DDA91C6477B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5DCD7348-929B-42BE-A1CD-5DDA91C6477B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5DCD7348-929B-42BE-A1CD-5DDA91C6477B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/source/Samples/.gitignore b/source/Samples/.gitignore
new file mode 100644
index 0000000..42abb80
--- /dev/null
+++ b/source/Samples/.gitignore
@@ -0,0 +1,3 @@
+*.csproj.teamcity
+*.js
+*.js.map
diff --git a/source/Samples/Sample.ConsoleApp/Sample.ConsoleApp.csproj.teamcity b/source/Samples/Sample.ConsoleApp/Sample.ConsoleApp.csproj.teamcity
deleted file mode 100644
index eccf369..0000000
--- a/source/Samples/Sample.ConsoleApp/Sample.ConsoleApp.csproj.teamcity
+++ /dev/null
@@ -1,61 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {77368AC2-07C1-4EB9-9575-327823B2240F}
- Exe
- Properties
- Sample.ConsoleApp
- Sample.ConsoleApp
- v4.0
- 512
-
-
- AnyCPU
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- App.config
-
-
-
-
-
-
\ No newline at end of file
diff --git a/source/Samples/Sample.ConsoleAppWithGitVersion/Sample.ConsoleAppWithGitVersion.csproj.teamcity b/source/Samples/Sample.ConsoleAppWithGitVersion/Sample.ConsoleAppWithGitVersion.csproj.teamcity
deleted file mode 100644
index 8a65c88..0000000
--- a/source/Samples/Sample.ConsoleAppWithGitVersion/Sample.ConsoleAppWithGitVersion.csproj.teamcity
+++ /dev/null
@@ -1,61 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {77368AC2-07C1-4EB9-9575-327823B2240F}
- Exe
- Properties
- Sample.ConsoleAppWithGitVersion
- Sample.ConsoleAppWithGitVersion
- v4.0
- 512
-
-
- AnyCPU
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- App.config
-
-
-
-
-
-
\ No newline at end of file
diff --git a/source/Samples/Sample.ConsoleAppWithNamespacedGitVersion/Sample.ConsoleAppWithNamespacedGitVersion.csproj.teamcity b/source/Samples/Sample.ConsoleAppWithNamespacedGitVersion/Sample.ConsoleAppWithNamespacedGitVersion.csproj.teamcity
deleted file mode 100644
index 8a65c88..0000000
--- a/source/Samples/Sample.ConsoleAppWithNamespacedGitVersion/Sample.ConsoleAppWithNamespacedGitVersion.csproj.teamcity
+++ /dev/null
@@ -1,61 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {77368AC2-07C1-4EB9-9575-327823B2240F}
- Exe
- Properties
- Sample.ConsoleAppWithGitVersion
- Sample.ConsoleAppWithGitVersion
- v4.0
- 512
-
-
- AnyCPU
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- App.config
-
-
-
-
-
-
\ No newline at end of file
diff --git a/source/Samples/Sample.TypeScriptApp/Scripts/MyTypedScript.UI.js b/source/Samples/Sample.TypeScriptApp/Scripts/MyTypedScript.UI.js
deleted file mode 100644
index eab30d2..0000000
--- a/source/Samples/Sample.TypeScriptApp/Scripts/MyTypedScript.UI.js
+++ /dev/null
@@ -1,4 +0,0 @@
-function greeter2(person) {
- return "Hello, " + person.firstname + " " + person.lastname;
-}
-var user = { firstname: "Jane", lastname: "User" };
diff --git a/source/Samples/Sample.TypeScriptApp/Scripts/MyTypedScript.UI.js.map b/source/Samples/Sample.TypeScriptApp/Scripts/MyTypedScript.UI.js.map
deleted file mode 100644
index 90cfb3f..0000000
--- a/source/Samples/Sample.TypeScriptApp/Scripts/MyTypedScript.UI.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"MyTypedScript.UI.js","sourceRoot":"","sources":["MyTypedScript.UI.ts"],"names":["greeter2"],"mappings":"AAKA,SAAS,QAAQ,CAAC,MAAc;IAC5BA,MAAMA,CAACA,SAASA,GAAGA,MAAMA,CAACA,SAASA,GAAGA,GAAGA,GAAGA,MAAMA,CAACA,QAAQA,CAACA;AAChEA,CAACA;AAED,IAAI,IAAI,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC"}
\ No newline at end of file
diff --git a/source/Samples/Sample.TypeScriptApp/Scripts/MyTypedScript.js b/source/Samples/Sample.TypeScriptApp/Scripts/MyTypedScript.js
deleted file mode 100644
index 184af89..0000000
--- a/source/Samples/Sample.TypeScriptApp/Scripts/MyTypedScript.js
+++ /dev/null
@@ -1,4 +0,0 @@
-function greeter(person) {
- return "Hello, " + person.firstname + " " + person.lastname;
-}
-var user = { firstname: "Jane", lastname: "User" };
diff --git a/source/Samples/Sample.TypeScriptApp/Scripts/MyTypedScript.js.map b/source/Samples/Sample.TypeScriptApp/Scripts/MyTypedScript.js.map
deleted file mode 100644
index 09fd2c2..0000000
--- a/source/Samples/Sample.TypeScriptApp/Scripts/MyTypedScript.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"MyTypedScript.js","sourceRoot":"","sources":["MyTypedScript.ts"],"names":["greeter"],"mappings":"AAKA,SAAS,OAAO,CAAC,MAAc;IAC3BA,MAAMA,CAACA,SAASA,GAAGA,MAAMA,CAACA,SAASA,GAAGA,GAAGA,GAAGA,MAAMA,CAACA,QAAQA,CAACA;AAChEA,CAACA;AAED,IAAI,IAAI,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC"}
\ No newline at end of file
diff --git a/source/packages/NUnitTestAdapter.2.3.0/.signature.p7s b/source/packages/NUnitTestAdapter.2.3.0/.signature.p7s
new file mode 100644
index 0000000..8682e6c
Binary files /dev/null and b/source/packages/NUnitTestAdapter.2.3.0/.signature.p7s differ
diff --git a/source/packages/NUnitTestAdapter.2.3.0/LICENSE.txt b/source/packages/NUnitTestAdapter.2.3.0/LICENSE.txt
new file mode 100644
index 0000000..68da1e1
--- /dev/null
+++ b/source/packages/NUnitTestAdapter.2.3.0/LICENSE.txt
@@ -0,0 +1,21 @@
+Copyright (c) 2011-2020 Charlie Poole
+Copyright (c) 2014-2020 Terje Sandstrom
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
diff --git a/source/packages/NUnitTestAdapter.2.3.0/NUnitTestAdapter.2.3.0.nupkg b/source/packages/NUnitTestAdapter.2.3.0/NUnitTestAdapter.2.3.0.nupkg
new file mode 100644
index 0000000..06a139c
Binary files /dev/null and b/source/packages/NUnitTestAdapter.2.3.0/NUnitTestAdapter.2.3.0.nupkg differ
diff --git a/source/packages/NUnitTestAdapter.2.3.0/build/Mono.Cecil.Mdb.dll b/source/packages/NUnitTestAdapter.2.3.0/build/Mono.Cecil.Mdb.dll
new file mode 100644
index 0000000..1f03289
Binary files /dev/null and b/source/packages/NUnitTestAdapter.2.3.0/build/Mono.Cecil.Mdb.dll differ
diff --git a/source/packages/NUnitTestAdapter.2.3.0/build/Mono.Cecil.Pdb.dll b/source/packages/NUnitTestAdapter.2.3.0/build/Mono.Cecil.Pdb.dll
new file mode 100644
index 0000000..0c4dd59
Binary files /dev/null and b/source/packages/NUnitTestAdapter.2.3.0/build/Mono.Cecil.Pdb.dll differ
diff --git a/source/packages/NUnitTestAdapter.2.3.0/build/Mono.Cecil.Rocks.dll b/source/packages/NUnitTestAdapter.2.3.0/build/Mono.Cecil.Rocks.dll
new file mode 100644
index 0000000..0f37b8c
Binary files /dev/null and b/source/packages/NUnitTestAdapter.2.3.0/build/Mono.Cecil.Rocks.dll differ
diff --git a/source/packages/NUnitTestAdapter.2.3.0/build/Mono.Cecil.dll b/source/packages/NUnitTestAdapter.2.3.0/build/Mono.Cecil.dll
new file mode 100644
index 0000000..9dc7206
Binary files /dev/null and b/source/packages/NUnitTestAdapter.2.3.0/build/Mono.Cecil.dll differ
diff --git a/source/packages/NUnitTestAdapter.2.3.0/build/NUnit.VisualStudio.TestAdapter.dll b/source/packages/NUnitTestAdapter.2.3.0/build/NUnit.VisualStudio.TestAdapter.dll
new file mode 100644
index 0000000..85b535b
Binary files /dev/null and b/source/packages/NUnitTestAdapter.2.3.0/build/NUnit.VisualStudio.TestAdapter.dll differ
diff --git a/source/packages/NUnitTestAdapter.2.3.0/build/NUnitTestAdapter.props b/source/packages/NUnitTestAdapter.2.3.0/build/NUnitTestAdapter.props
new file mode 100644
index 0000000..358a19e
--- /dev/null
+++ b/source/packages/NUnitTestAdapter.2.3.0/build/NUnitTestAdapter.props
@@ -0,0 +1,46 @@
+
+
+
+
+ NUnit.VisualStudio.TestAdapter.dll
+ PreserveNewest
+ False
+
+
+ Mono.Cecil.dll
+ PreserveNewest
+ False
+
+
+ Mono.Cecil.Mdb.dll
+ PreserveNewest
+ False
+
+
+ Mono.Cecil.Pdb.dll
+ PreserveNewest
+ False
+
+
+ Mono.Cecil.Rocks.dll
+ PreserveNewest
+ False
+
+
+ nunit.core.dll
+ PreserveNewest
+ False
+
+
+ nunit.core.interfaces.dll
+ PreserveNewest
+ False
+
+
+ nunit.util.dll
+ PreserveNewest
+ False
+
+
+
+
diff --git a/source/packages/NUnitTestAdapter.2.3.0/build/nunit.core.dll b/source/packages/NUnitTestAdapter.2.3.0/build/nunit.core.dll
new file mode 100644
index 0000000..0c375b8
Binary files /dev/null and b/source/packages/NUnitTestAdapter.2.3.0/build/nunit.core.dll differ
diff --git a/source/packages/NUnitTestAdapter.2.3.0/build/nunit.core.interfaces.dll b/source/packages/NUnitTestAdapter.2.3.0/build/nunit.core.interfaces.dll
new file mode 100644
index 0000000..be28783
Binary files /dev/null and b/source/packages/NUnitTestAdapter.2.3.0/build/nunit.core.interfaces.dll differ
diff --git a/source/packages/NUnitTestAdapter.2.3.0/build/nunit.util.dll b/source/packages/NUnitTestAdapter.2.3.0/build/nunit.util.dll
new file mode 100644
index 0000000..dd915a6
Binary files /dev/null and b/source/packages/NUnitTestAdapter.2.3.0/build/nunit.util.dll differ
diff --git a/source/tools/Install.ps1 b/source/tools/Install.ps1
index f7f330e..2928684 100644
--- a/source/tools/Install.ps1
+++ b/source/tools/Install.ps1
@@ -3,16 +3,16 @@ param($installPath, $toolsPath, $package, $project)
$buildPath = '..\build'
$targetsFile = [System.IO.Path]::Combine($toolsPath, $buildPath, $package.Id + '.targets')
$targetsFile = [System.IO.Path]::GetFullPath($targetsFile)
-
+
# Need to load MSBuild assembly if it's not loaded yet.
Add-Type -AssemblyName 'Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
# Grab the loaded MSBuild project for the project
$msbuild = [Microsoft.Build.Evaluation.ProjectCollection]::GlobalProjectCollection.GetLoadedProjects($project.FullName) | Select-Object -First 1
- #Short circuit if OctoPack has already been installed (this could be by convention in newer versions of NuGet)
+ # Short circuit if OctoPack has already been installed (this could be by convention in newer versions of NuGet)
$existingImports = @()
- $existingImports = $existingImports += $msbuild.Xml.Imports | Where-Object { $_.Project.EndsWith($package.Id + '.targets') }
+ $existingImports = $existingImports += $msbuild.Xml.Imports | Where-Object { $_.Project -imatch "$($package.Id)\.targets`$" }
if ($existingImports -and $existingImports.length)
{
Write-Host "It looks like OctoPack has been installed, skipping Install.ps1"
@@ -20,10 +20,11 @@ param($installPath, $toolsPath, $package, $project)
}
# Make the path to the targets file relative.
- $projectUri = new-object Uri($project.FullName, [System.UriKind]::Absolute)
+ $projectUri = new-object Uri -ArgumentList $project.FullName, [System.UriKind]::Absolute
+
$targetUri = new-object Uri($targetsFile, [System.UriKind]::Absolute)
$relativePath = [System.Uri]::UnescapeDataString($projectUri.MakeRelativeUri($targetUri).ToString()).Replace([System.IO.Path]::AltDirectorySeparatorChar, [System.IO.Path]::DirectorySeparatorChar)
-
+
# Add the import with a condition, to allow the project to load without the targets present.
$import = $msbuild.Xml.AddImport($relativePath)
$import.Condition = "Exists('$relativePath')"
diff --git a/source/tools/Uninstall.ps1 b/source/tools/Uninstall.ps1
index b635c33..62faa74 100644
--- a/source/tools/Uninstall.ps1
+++ b/source/tools/Uninstall.ps1
@@ -1,5 +1,5 @@
param($installPath, $toolsPath, $package, $project)
-
+
# Need to load MSBuild assembly if it's not loaded yet.
Add-Type -AssemblyName 'Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
@@ -10,41 +10,37 @@ param($installPath, $toolsPath, $package, $project)
$itemsToRemove = @()
# Allow many in case a past package was incorrectly uninstalled
- $itemsToRemove += $msbuild.Xml.Imports | Where-Object { $_.Project.EndsWith($package.Id + '.targets') }
+ $itemsToRemove += $msbuild.Xml.Imports | Where-Object { $_.Project -imatch "$($package.Id)\.targets`$" }
$itemsToRemove += $msbuild.Xml.Targets | Where-Object { $_.Name -eq "EnsureOctoPackImported" }
-
+
$saveProject = $false
# Remove the elements and save the project
$saveProject = ($itemsToRemove -and $itemsToRemove.length)
- foreach ($itemToRemove in $itemsToRemove)
- {
- $msbuild.Xml.RemoveChild($itemToRemove) | out-null
- }
-
- $targetImports = @()
- $targetImports += $msbuild.Xml.Targets | Where-Object { $_.Name -eq "EnsureNuGetPackageBuildImports" }
- foreach ($targetImport in $targetImports)
- {
- $targetImportsToRemove = @()
- $targetImportsToRemove += $targetImports.Children | Where-Object { $_.Condition.Contains($package.Id + '.targets') }
+ $itemsToRemove | ForEach-Object { <#$null = #> $msbuild.Xml.RemoveChild($_) }
- $saveProject = $saveProject -or ($targetImportsToRemove -and $targetImportsToRemove.length)
- foreach ($targetImport in $targetImportsToRemove)
- {
- $targetImports.RemoveChild($targetImport)
- }
- }
+ $msbuild.Xml.Targets |
+ Where-Object { $_.Name -eq "EnsureNuGetPackageBuildImports" } |
+ ForEach-Object {
+ $target = $_;
+ $target.Children |
+ Where-Object { $_.Condition -imatch "$($package.Id)\.targets" } |
+ ForEach-Object {
+ # This only gets evaluated if the collection has items to enumerate over...
+ if (!$saveProject) { $saveProject = $true }
+ $target.RemoveChild($_)
+ }
+ }
if ($saveProject)
{
- $isFSharpProject = ($project.Type -eq "F#")
- if ($isFSharpProject)
- {
- $project.Save("")
- }
- else
- {
- $project.Save()
- }
+ $isFSharpProject = ($project.Type -eq "F#")
+ if ($isFSharpProject)
+ {
+ $project.Save("")
+ }
+ else
+ {
+ $project.Save()
+ }
}
\ No newline at end of file