-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDotNetPublish.Task.ps1
41 lines (37 loc) · 1.81 KB
/
DotNetPublish.Task.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Add-BuildTask DotNetPublish @{
# This task should be skipped if there are no C# projects to build
If = $dotnetProjects
Inputs = {
# Exclude generated source files in /obj/ folders
Get-ChildItem (Split-Path $dotnetProjects) -Recurse -File -Filter *.cs |
Where-Object FullName -NotMatch "[\\/]obj[\\/]"
}
Outputs = {
foreach ($project in $dotnetProjects) {
$Name = Split-Path $project -LeafBase
$OutputFolder = @($dotnetProjects).Count -gt 1 ? "$DotNetPublishRoot${/}$Name" : $DotNetPublishRoot
$Expected = Join-Path $OutputFolder -ChildPath "$Name.dll"
Write-Host "Expected Output: $Expected"
$Expected
}
}
Jobs = "DotNetBuild", {
$local:options = @{} + $script:dotnetOptions
$script:DotNetPublishRoot = New-Item $script:DotNetPublishRoot -ItemType Directory -Force -ErrorAction SilentlyContinue | Convert-Path
# We never do self-contained builds
if ($options.ContainsKey("-runtime") -or $options.ContainsKey("-ucr")) {
$options["-no-self-contained"] = $true
}
foreach ($project in $dotnetProjects) {
$Name = Split-Path $project -LeafBase
Write-Host "Publishing $Name"
if ($GitVersion.$Name) {
$options["p"] = "Version=$($GitVersion.$Name.InformationalVersion)"
}
Set-Location (Split-Path $project)
$OutputFolder = @($dotnetProjects).Count -gt 1 ? "$DotNetPublishRoot${/}$Name" : $DotNetPublishRoot
Write-Build Gray "dotnet publish $project --output $OutputFolder --no-build --configuration $configuration -p $($options["p"])"
dotnet publish $project --output "$OutputFolder" --no-build --configuration $configuration
}
}
}