Skip to content

Commit

Permalink
Update PSGallery #30
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonZiminSaritasa committed Nov 10, 2017
1 parent 27129ba commit ae04ace
Show file tree
Hide file tree
Showing 22 changed files with 1,035 additions and 287 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'Saritasa.Build'

# Version number of this module.
ModuleVersion = '1.15.0'
ModuleVersion = '1.16.0'

# ID used to uniquely identify this module
GUID = '5d34804a-169a-4fb1-bc0d-cc81f925f992'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<#
.SYNOPSIS
Downloads nuget.exe to specified location.
Downloads latest nuget.exe to specified location.
.EXAMPLE
Install-NugetCli .
Install nuget into current directory
#>
function Install-NugetCli
{
Expand All @@ -26,17 +31,28 @@ function Install-NugetCli
<#
.SYNOPSIS
Restores packages for solution, project or packages.config.
.EXAMPLE
Invoke-NugetRestore .\..\myapp.sln
Restores all packages for myapp solution.
.NOTES
If nuget command is not found - it will be downloaded to current directory.
#>
function Invoke-NugetRestore
{
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true, HelpMessage = 'Path to solution. All NuGet packages from included projects will be restored.', ParameterSetName = 'Solution')]
# Path to solution. All NuGet packages from included projects will be restored.
[Parameter(Mandatory = $true, ParameterSetName = 'Solution')]
[string] $SolutionPath,
[Parameter(Mandatory = $true, HelpMessage = 'Path to project or packages.config.', ParameterSetName = 'Project')]
# Path to project or packages.config.
[Parameter(Mandatory = $true, ParameterSetName = 'Project')]
[string] $ProjectPath,
[Parameter(Mandatory = $true, HelpMessage = 'Path to the solution directory. Not valid when restoring packages for a solution.', ParameterSetName = 'Project')]
# Path to the solution directory. Not valid when restoring packages for a solution.
[Parameter(Mandatory = $true, ParameterSetName = 'Project')]
[string] $SolutionDirectory
)

Expand Down Expand Up @@ -71,14 +87,22 @@ function Invoke-NugetRestore
}
}

<#
.SYNOPSIS
Builds solution.
.EXAMPLE
Invoke-SolutionBuild .\..\myapp.sln -Configuration Debug
#>
function Invoke-SolutionBuild
{
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true, HelpMessage = 'Path to solution.')]
# Path to solution.
[Parameter(Mandatory = $true)]
[string] $SolutionPath,
[Parameter(HelpMessage = 'Build configuration (Release, Debug, etc.)')]
# Build configuration (Release, Debug, etc.)
[string] $Configuration
)

Expand All @@ -87,16 +111,32 @@ function Invoke-SolutionBuild
Invoke-ProjectBuild $SolutionPath $Configuration
}

<#
.SYNOPSIS
Builds project.
.PARAMETER Target
Build the specified targets in the project.
Use a semicolon or comma to separate multiple targets.
.EXAMPLE
Invoke-ProjectBuild .\..\Web\Web.csproj -Configuration 'Release'
.NOTES
For more information about Target and BuildParams parameters, see MSBuild documentation.
#>
function Invoke-ProjectBuild
{
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true, HelpMessage = 'Path to project.')]
# Path to project.
[Parameter(Mandatory = $true)]
[string] $ProjectPath,
[Parameter(HelpMessage = 'Build configuration (Release, Debug, etc.)')]
# Build configuration (Release, Debug, etc.)
[string] $Configuration,
[string] $Target = 'Build',
# Additional build parameters.
[string[]] $BuildParams
)

Expand All @@ -113,6 +153,12 @@ function Invoke-ProjectBuild
.SYNOPSIS
Update version numbers of AssemblyInfo.cs and AssemblyInfo.vb.
.DESCRIPTION
Updates version numbers in AssemblyInfo files located in current directory and all subdirectories.
.EXAMPLE
Update-AssemblyInfoFile '6.3.1.1'
.NOTES
Based on SetVersion script.
http://www.luisrocha.net/2009/11/setting-assembly-version-with-windows.html
Expand All @@ -123,7 +169,8 @@ function Update-AssemblyInfoFile
[CmdletBinding(SupportsShouldProcess = $true)]
param
(
[Parameter(Mandatory = $true, HelpMessage = 'Version string in major.minor.build.revision format.')]
# Version string in major.minor.build.revision format.
[Parameter(Mandatory = $true)]
[string] $Version
)

Expand All @@ -136,7 +183,7 @@ function Update-AssemblyInfoFile

Get-ChildItem -r -Include AssemblyInfo.cs, AssemblyInfo.vb | ForEach-Object `
{
$filename = $_.Directory.ToString() + '\' + $_.Name
$filename = $_.FullName

# If you are using a source control that requires to check-out files before
# modifying them, make sure to check-out the file here.
Expand All @@ -147,21 +194,34 @@ function Update-AssemblyInfoFile
{
(Get-Content $filename) | ForEach-Object `
{
ForEach-Object { $_ -replace $assemblyVersionPattern, $assemblyVersion } |
ForEach-Object { $_ -replace $fileVersionPattern, $fileVersion }
($_ -replace $assemblyVersionPattern, $assemblyVersion) `
-replace $fileVersionPattern, $fileVersion
} | Set-Content $filename -Encoding UTF8

Write-Information ($filename + ' -> ' + $Version)
Write-Information "$filename -> $Version"
}
}
}

<#
.SYNOPSIS
Creates file from a template.
.DESCRIPTION
Creates a config file from it's template. If file already exists, it will not be overridden.
.EXAMPLE
Copy-DotnetConfig .\..\Web\Web.config.template
Creates a Web.config file in Web folder from template.
#>
function Copy-DotnetConfig
{
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true, HelpMessage = 'Path to App.config.template or Web.config.template file.')]
# Path to App.config.template or Web.config.template file.
[Parameter(Mandatory = $true)]
[string] $TemplateFilename
)

Expand All @@ -178,6 +238,11 @@ function Copy-DotnetConfig
.SYNOPSIS
Run Entity Framework migrations.
.EXAMPLE
Invoke-EFMigrate ..\..\Domain\bin\Debug\Domain.dll
Runs all migrations declared in Domain.dll file, using Domain.dll.config as configuration file
.NOTES
In essential this command tries to find migrate.exe in packages and run it against specified
configuration file.
Expand All @@ -187,9 +252,10 @@ function Invoke-EFMigrate
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true, HelpMessage = 'Path to assembly file with migrations.')]
# Path to assembly file with migrations.
[Parameter(Mandatory = $true)]
[string] $MigrationAssembly,
[Parameter(HelpMessage = 'Path to assembly .config file. If not specified default or parent Web.config will be used.')]
# Path to assembly .config file. If not specified default or parent Web.config will be used.
[string] $ConfigFilename
)

Expand Down Expand Up @@ -220,15 +286,15 @@ function Invoke-EFMigrate
{
throw 'Cannot find packages directory.'
}
Write-Information "Found $packagesDirectory.FullName"
Write-Information "Found $($packagesDirectory.FullName)"
$migrateExeDirectory = Get-ChildItem $packagesDirectory.FullName 'EntityFramework.*' |
Sort-Object { $_.Name } | Select-Object -Last 1
if (!$migrateExeDirectory)
{
throw 'Cannot find entity framework package.'
}
$migrateExe = Join-Path $migrateExeDirectory.FullName '.\tools\migrate.exe'
Write-Information "Found $migrateExeDirectory.FullName"
Write-Information "Found $($migrateExeDirectory.FullName)"

# Run migrate
$workingDirectory = Get-Location
Expand All @@ -247,6 +313,7 @@ function Invoke-EFMigrate
<#
.SYNOPSIS
Replaces placeholders $(UserName) with values from hashtable.
.EXAMPLE
Update-VariablesInFile -Path Config.xml @{UserName='sa'}
#>
Expand Down Expand Up @@ -303,14 +370,16 @@ function Initialize-MSBuild
$msbuildPath = Join-Path $vsPath 'MSBuild\15.0\Bin'
}

$env:Path = $msbuildPath + ";$env:Path"
$env:Path = "$msbuildPath;$env:Path"
}

<#
.SYNOPSIS
Loads packages from many packages.config and saves to a single file.
Loads packages from multiple packages.config and saves to a single file.
.EXAMPLE
Merge-PackageConfigs -SolutionDirectory .\src -OutputPath .\src\packages.merged.config
.EXAMPLE
Merge-PackageConfigs -SolutionDirectory .\src -OutputPath .\src\packages.merged.net40.config -Framework net40
Merge-PackageConfigs -SolutionDirectory .\src -OutputPath .\src\packages.merged.net452.config -Framework net452
Expand All @@ -320,24 +389,26 @@ function Merge-PackageConfigs
[CmdletBinding()]
param
(
# Directory in which to look for packages.config files.
[Parameter(Mandatory = $true)]
[string] $SolutionDirectory,
# Path to file in which results should be saved. If file exists, it will be overridden.
[Parameter(Mandatory = $true)]
[string] $OutputPath,
[Parameter]
# If specified, only packages with this framework will be included in the results.
[string] $Framework
)

Get-CallerPreference -Cmdlet $PSCmdlet -SessionState $ExecutionContext.SessionState

$files = Get-ChildItem $src -Recurse packages.config
$files = Get-ChildItem $SolutionDirectory -Recurse packages.config

$packagesSet = New-Object 'System.Collections.Generic.HashSet[string]'

foreach ($file in $files)
{
[xml] $xml = Get-Content $file.FullName
$xml.packages.package | % `
$xml.packages.package | ForEach-Object `
{
if (!$Framework -or $_.targetFramework -eq $Framework)
{
Expand Down
Loading

0 comments on commit ae04ace

Please sign in to comment.