Skip to content

Commit

Permalink
Fix erroring out when solution file is not passed in explicitly.
Browse files Browse the repository at this point in the history
Solution file should have been optional. Also now throws when commands executed return non-0 exit result.
  • Loading branch information
AraHaan committed Jun 17, 2021
1 parent b43ea09 commit 54d97a0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea/
.DS_Store
19 changes: 9 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,25 @@ class Action {
return spawnSync(TOOL, ARGS, options)
}

_executeInProcess(cmd) {
this._executeCommand(cmd, { encoding: "utf-8", stdio: [process.stdin, process.stdout, process.stderr] })
_executeInProcess(cmd, errmsg) {
if (this._executeCommand(cmd, { encoding: "utf-8", stdio: [process.stdin, process.stdout, process.stderr] }).status > 0)
{
this._printErrorAndExit(errmsg)
}
}

run() {
if (!this.solutionFile || !fs.existsSync(this.solutionFile)) {
this._printErrorAndExit("solution file not found")
}

this._executeInProcess(`dotnet restore${this.solutionFile === "" ? this.solutionFile : ` ${this.solutionFile}`}`)
this._executeInProcess(`dotnet build -c Release --no-restore${this.solutionFile === "" ? this.solutionFile : ` ${this.solutionFile}`}`)
this._executeInProcess(`dotnet restore${this.solutionFile === "" ? this.solutionFile : ` ${this.solutionFile}`}`, `restore failed`)
this._executeInProcess(`dotnet build -c Release --no-restore${this.solutionFile === "" ? this.solutionFile : ` ${this.solutionFile}`}`, `build failed`)
if (this.test) {
this._executeInProcess(`dotnet test -c Release --no-build --no-restore${this.solutionFile === "" ? this.solutionFile : ` ${this.solutionFile}`}`)
this._executeInProcess(`dotnet test -c Release --no-build --no-restore${this.solutionFile === "" ? this.solutionFile : ` ${this.solutionFile}`}`, `testing failed`)
}

if (this.pack) {
console.log(`Note: To package symbol packages as well as normal packages specify these msbuild properties inside of the project's csproj file or to an Directory.Build.props file that is automatically imported by the .NET SDK:`)
console.log(`https://docs.microsoft.com/en-us/nuget/create-packages/symbol-packages-snupkg#creating-a-symbol-package`)
console.log(`setting these will be honored when calling dotnet pack and dotnet nugget push.`)
this._executeInProcess(`dotnet pack --no-build --no-restore -c Release${this.solutionFile === "" ? this.solutionFile : ` ${this.solutionFile}`}`)
this._executeInProcess(`dotnet pack --no-build --no-restore -c Release${this.solutionFile === "" ? this.solutionFile : ` ${this.solutionFile}`}`, `packing failed`)
}
}
}
Expand Down

0 comments on commit 54d97a0

Please sign in to comment.