Skip to content

Commit

Permalink
Update-Nuspec: Optional $ResolveDependecies
Browse files Browse the repository at this point in the history
  • Loading branch information
apobekiaris committed Jun 25, 2019
1 parent 98411d4 commit 2aa8629
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions XpandPwsh/Public/Nuget/Update-Nuspec.ps1
Expand Up @@ -15,7 +15,8 @@ function Update-Nuspec {
[string]$LibrariesFolder ,
$customPackageLinks = @{ },
[switch]$KeepDependencies,
[switch]$KeepFiles
[switch]$KeepFiles,
[bool]$ResolveNugetDependecies
)

begin {
Expand Down Expand Up @@ -55,7 +56,10 @@ function Update-Nuspec {
$outputPath = "$(Resolve-Path $outputPath)"
Pop-Location
$assemblyPath = "$outputPath\$id.dll"
$allDependencies = [System.Collections.ArrayList]::new((Resolve-AssemblyDependencies $assemblyPath -ErrorAction SilentlyContinue | ForEach-Object { $_.GetName().Name }))
$allDependencies=@()
if ($ResolveNugetDependecies){
$allDependencies = [System.Collections.ArrayList]::new((Resolve-AssemblyDependencies $assemblyPath -ErrorAction SilentlyContinue | ForEach-Object { $_.GetName().Name }))
}

$nuspec.package.metadata.version = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($assemblyPath).FileVersion

Expand All @@ -65,7 +69,7 @@ function Update-Nuspec {
if ($comma -ne -1 ) {
$packageName = $packageName.Substring(0, $comma)
}
if ($packageName -in $allDependencies) {
if (!$ResolveNugetDependecies -or $packageName -in $allDependencies) {
$matchedPackageName = $customPackageLinks[$packageName]
if (!$matchedPackageName) {
$projectName = Get-ChildItem $ProjectsRoot *.csproj -Recurse | Select-Object -ExpandProperty BaseName | Where-Object { $_ -eq $packageName } | Select-Object -First 1
Expand Down Expand Up @@ -102,7 +106,7 @@ function Update-Nuspec {
Id = $_.Include
Version = $_.Version
}
if ($_.Include -in $allDependencies) {
if (!$ResolveNugetDependecies -or $_.Include -in $allDependencies) {
Invoke-Command $AddDependency -ArgumentList $packageInfo
}
}
Expand Down

0 comments on commit 2aa8629

Please sign in to comment.