Skip to content

Commit

Permalink
Fix for dotnet Tooling 1.0
Browse files Browse the repository at this point in the history
- added suport for *.csproj
- added same Error handling to the nuget Task as in the Build Task
  • Loading branch information
kirkone committed Mar 7, 2017
1 parent 30eddc1 commit f592e1a
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 31 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Under the "**Advanced**" group you can decide if you want the source code to be
Also the "**Working Folder**" can be specified here. Usual this should be the folder where your .sln file is.
The field "**Source Folder**" is used to specify a subfolder where your projects are located. The default value is "src" like in a standard asp.net core project. If your project folders are direct in your "**Working Folder**" leave this field blank.

The Task will look in "**Working folder**/**Source Folder**/**Project Name**" for a project.json and starts building this project.
The Task will look in "**Working folder**/**Source Folder**/**Project Name**" for a project.json or a *.csproj and starts building this project.

This task will fail when no project can be found in the specified location.

Expand Down Expand Up @@ -105,6 +105,12 @@ Please have a look here: [GitHub Issues](https://github.com/kirkone/vsts-dnx-tas

### Release Notes

#### Version 0.1.26

- Fix for dotnet Tooling 1.0
- added suport for *.csproj
- added same Error handling to the nuget Task as in the Build Task

#### Version 0.1.25

- Fixed [Issue 23](https://github.com/kirkone/vsts-dnx-tasks/issues/23) Thanks to Tankatronic
Expand Down
124 changes: 104 additions & 20 deletions VSTS.DNX.Tasks.BuildNugetPackage/BuildNugetPackage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ param (

Write-Verbose "Entering script BuildNugetPackage.ps1"

Write-Output "Parameter Values:"
Write-Host "Parameter Values:"
foreach($key in $PSBoundParameters.Keys)
{
Write-Output (" $key = $($PSBoundParameters[$key])")
Write-Host (" $key = $($PSBoundParameters[$key])")
}
Write-Host " "

Function Main
{
Expand Down Expand Up @@ -61,39 +62,122 @@ Function Main

if([string]::IsNullOrWhiteSpace($ProjectName) -Or $projects.Count -eq 0 )
{
Write-Output "No Projects specified, build all..."
$projects = dir -Path "$SourceFolder*\*" -Filter project.json | % {
Write-Host "No Projects specified, build all..."
$projects = Get-ChildItem -Path "$SourceFolder*\*" -Filter *.csproj | ForEach-Object {
$_.Directory.Name
} | & {$input}
$projects += Get-ChildItem -Path "$SourceFolder*\*" -Filter project.json | ForEach-Object {
$_.Directory.Name
} | & {$input}
}

if($projects.Count -eq 0)
{
Write-Error "No projects found in Source Folder!"
return
Write-Host "No projects found in Source Folder!`n`r "
Write-Host "##vso[task.complete result=Failed;]No projects found in Source Folder!"
exit 1
}

Write-Output "$($projects.Count) Projects to build"

Write-Output "dotnet restore for:"
Write-Output $projects | % {" ""$SourceFolder$($_.Trim('"'))""" }
Write-Host " $($projects.Count) Projects to build`n`r "

$projectList = $projects | % {"""$SourceFolder$($_.Trim('"'))""" } | & {"$input"}
Invoke-Expression "& dotnet restore $projectList"
Write-Output " Restore done."
Write-Host "dotnet restore for:"
Write-Host " $($projectList -split(" ") | % { "$_" })`n`r "

Invoke-Expression "& dotnet restore $projectList" 2>&1 | Format-Console

if ($LASTEXITCODE -ne 0) {
Write-Host " Restore failed.`n`r "
Write-Host "##vso[task.complete result=Failed;]Restore Failed!"
exit 1
}
Write-Host " Restore done.`n`r "

Write-Host "dotnet build for:"
Write-Host " $($projectList -split(" ") | % { "$_" })`n`r "
Invoke-Expression "& dotnet build $projectList -c $BuildConfiguration --no-incremental" 2>&1 -ErrorVariable buildIssues | Format-Console

$buildWarnings = $buildIssues | Where-Object {$_ -like "*: warning *"}
$buildErrors = $buildIssues | Where-Object {$_ -like "*: error *"}

if ($buildWarnings.Count -gt 0)
{
Write-Host " Warnings:`n`r "
foreach($warning in $buildWarnings)
{
if ($warning -ne [string]::IsNullOrWhiteSpace($warning))
{
Write-Host "##vso[task.logissue type=warning;]Warning: $warning"
}
}

Write-Host " `n`r "
}

if ($buildErrors.Count -gt 0)
{
Write-Host " Errors:`n`r "
foreach($error in $buildErrors)
{
if ($error -ne [string]::IsNullOrWhiteSpace($error) -and
-not ($error -like "*dotnet-compile.rsp returned Exit Code 1*"))
{
Write-Host "##vso[task.logissue type=error;]Error: $error"
}
}

Write-Host "##vso[task.complete result=Failed;]Build Failed!"
Write-Host " Build Failed!`n`r "
Write-Host " "

exit 1
}

Write-Output "dotnet build for:"
Write-Output $($projectList -split(" ") | % { " $_" })
Invoke-Expression "& dotnet build $projectList -c $BuildConfiguration"
Write-Output " Build done."
Write-Host " Build done.`n`r "

foreach($project in $projects)
{
$p = "$SourceFolder$($project.Trim('"'))"
Write-Output "dotnet pack for:"
Write-Output " $p"
Invoke-Expression "& dotnet pack $p -c $BuildConfiguration -o ""$OutputFolder"" $versionSuffix"
Write-Output " Pack done for: $p"
Write-Host "dotnet pack for:"
Write-Host " ""$p""`n`r "

Invoke-Expression "& dotnet pack $p -c $BuildConfiguration -o ""$OutputFolder"" $versionSuffix" 2>&1 -ErrorVariable packIssues | Format-Console

$packWarnings = $packIssues | Where-Object {$_ -like "*: warning *"}
$packErrors = $packIssues | Where-Object {$_ -like "*: error *"}

if ($packWarnings.Count -gt 0)
{
Write-Host " Warnings:`n`r "
foreach($warning in $packWarnings)
{
if ($warning -ne [string]::IsNullOrWhiteSpace($warning))
{
Write-Host "##vso[task.logissue type=warning;]Warning: $warning"
}
}

Write-Host " `n`r "
}

if ($packErrors.Count -gt 0)
{
Write-Host " Errors:`n`r "
foreach($error in $packErrors)
{
if ($error -ne [string]::IsNullOrWhiteSpace($error))
{
Write-Host "##vso[task.logissue type=error;]Error: $error"
}
}

Write-Host "##vso[task.complete result=Failed;]Pack Failed!"
Write-Host " Pack Failed!`n`r "
Write-Host " "

exit 1
}
Write-Host " `n`r Pack done for: $p`n`r "
}
}

Expand Down
4 changes: 2 additions & 2 deletions VSTS.DNX.Tasks.BuildNugetPackage/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"name": "DNX.Tasks.BuildNugetPackage",
"friendlyName": "DNX Tasks Build Nuget Package",
"description": "Build a Nuget package with dotnet cli.",
"helpMarkDown": "Version: 0.1.23",
"helpMarkDown": "Version: 0.1.24",
"category": "Build",
"author": "Kirsten Kluge",
"version": {
"Major": 0,
"Minor": 1,
"Patch": 23
"Patch": 24
},
"visibility": [
"Build"
Expand Down
14 changes: 9 additions & 5 deletions VSTS.DNX.Tasks.BuildWebPackage/BuildWebPackage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ Function Main
if([string]::IsNullOrWhiteSpace($ProjectName) -Or $projects.Count -eq 0 )
{
Write-Host "No Projects specified, build all..."
$projects = dir -Path "$SourceFolder*\*" -Filter project.json | % {
$projects = Get-ChildItem -Path "$SourceFolder*\*" -Filter *.csproj | ForEach-Object {
$_.Directory.Name
} | & {$input}
$projects += Get-ChildItem -Path "$SourceFolder*\*" -Filter project.json | ForEach-Object {
$_.Directory.Name
} | & {$input}
}
Expand All @@ -66,6 +69,7 @@ Function Main

Write-Host " $($projects.Count) Projects to build`n`r "


$projectList = $projects | % {"""$SourceFolder$($_.Trim('"'))""" } | & {"$input"}
Write-Host "dotnet restore for:"
Write-Host " $($projectList -split(" ") | % { "$_" })`n`r "
Expand All @@ -83,8 +87,8 @@ Function Main
Write-Host " $($projectList -split(" ") | % { "$_" })`n`r "
Invoke-Expression "& dotnet build $projectList -c $BuildConfiguration --no-incremental" 2>&1 -ErrorVariable buildIssues | Format-Console

$buildWarnings = $buildIssues|where{$_ -like "*: warning *"}
$buildErrors = $buildIssues|where{$_ -like "*: error *"}
$buildWarnings = $buildIssues | Where-Object {$_ -like "*: warning *"}
$buildErrors = $buildIssues | Where-Object {$_ -like "*: error *"}

if ($buildWarnings.Count -gt 0)
{
Expand Down Expand Up @@ -129,8 +133,8 @@ Function Main
Write-Host " ""$p""`n`r "
Invoke-Expression "& dotnet publish $p -c $BuildConfiguration -o ""$OutputFolder\$outDir"" --no-build " 2>&1 -ErrorVariable publishIssues | Format-Console

$publishWarnings = $publishIssues|where{$_ -like "*: warning *"}
$publishErrors = $publishIssues|where{$_ -like "*: error *"}
$publishWarnings = $publishIssues | Where-Object {$_ -like "*: warning *"}
$publishErrors = $publishIssues | Where-Object {$_ -like "*: error *"}

if ($publishWarnings.Count -gt 0)
{
Expand Down
4 changes: 2 additions & 2 deletions VSTS.DNX.Tasks.BuildWebPackage/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"name": "DNX.Tasks.BuildWebPackage",
"friendlyName": "DNX Tasks Build Web Package",
"description": "Build a package with dotnet cli for Deployment",
"helpMarkDown": "Version: 0.1.24",
"helpMarkDown": "Version: 0.1.25",
"category": "Build",
"author": "Kirsten Kluge",
"version": {
"Major": 0,
"Minor": 1,
"Patch": 24
"Patch": 25
},
"visibility": [
"Build"
Expand Down
2 changes: 1 addition & 1 deletion vss-extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifestVersion": 1,
"id": "vsts-dnx-tasks",
"name": "VSTS DNX Tasks",
"version": "0.1.25",
"version": "0.1.26",
"publisher": "kirkone",
"public": true,
"targets": [
Expand Down

0 comments on commit f592e1a

Please sign in to comment.