Skip to content

Instantly share code, notes, and snippets.

@pimbrouwers
Last active December 3, 2022 01:44
Show Gist options
  • Save pimbrouwers/6482e7e9e713faafda23189e4ace3bd8 to your computer and use it in GitHub Desktop.
Save pimbrouwers/6482e7e9e713faafda23189e4ace3bd8 to your computer and use it in GitHub Desktop.
Invoke-DotnetExe.ps1
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, HelpMessage = "The path to the project")]
[String]
$Project,
[Parameter(Mandatory = $true, HelpMessage = "The .NET Runtime Identifier")]
[ValidateSet("win-x64")]
[String]
$Rid,
[Parameter(HelpMessage = "The build config to use")]
[ValidateSet("Release", "Debug")]
[String]
$Config = "Release"
)
" ____ ____ _______ ______________ _______ __ ______
/ __ \/ __ \/_ __/ | / / ____/_ __/ / ____/ |/ // ____/
/ / / / / / / / / / |/ / __/ / / / __/ | // __/
/ /_/ / /_/ / / / / /| / /___ / / / /___ / |/ /___
/_____/\____/ /_/ /_/ |_/_____/ /_/ /_____//_/|_/_____/
"
function RunCommand {
param ([string] $CommandExpr)
Write-Verbose " $CommandExpr"
Invoke-Expression $CommandExpr
}
$props =
@(
"PublishSingleFile=true"
"PublishReadyToRun=true"
"PublishTrimmed=true"
"IncludeNativeLibrariesForSelfExtract=true"
"DebuggerSupport=false"
"EnableUnsafeUTF7Encoding=false"
"HttpActivityPropagationSupport=false"
"InvariantGlobalization=true"
"UseNativeHttpHandler=true"
"UseSystemResourceKeys=true"
"EnableCompressionInSingleFile=true"
)
$propsArgs = "-p:" + ($props -join " -p:")
$dotnetExrp = "dotnet publish $Project -c $Config -r $Rid --self-contained true $propsArgs"
RunCommand $dotnetExrp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment