Skip to content

Commit

Permalink
Merge pull request #38 from nblumhardt/still-no-tool
Browse files Browse the repository at this point in the history
Still no luck getting the tool package working; pulling out some more tricks
  • Loading branch information
nblumhardt authored May 22, 2024
2 parents 6077136 + 4faf650 commit ac2e84e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 23 deletions.
8 changes: 4 additions & 4 deletions Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ if ($suffix) {
}
if($LASTEXITCODE -ne 0) { exit 11 }

# Stale artifacts cause problems, we change the output type but MSBuild doesn't notice.
& dotnet clean $project
if($LASTEXITCODE -ne 0) { exit 11 }

Write-Output "build: Packing executable into dotnet tool Datalust.Piggy.Cli.*.nupkg"
if ($suffix) {
& dotnet build $project --no-incremental -c Release -o $PSScriptRoot/$artifacts /p:PackAsTool=True --version-suffix=$suffix
if($LASTEXITCODE -ne 0) { exit 11 }
& dotnet pack $project -c Release -o $PSScriptRoot/$artifacts /p:PackAsTool=True --version-suffix=$suffix
} else {
& dotnet build $project --no-incremental -c Release -o $PSScriptRoot/$artifacts /p:PackAsTool=True
if($LASTEXITCODE -ne 0) { exit 11 }
& dotnet pack $project -c Release -o $PSScriptRoot/$artifacts /p:PackAsTool=True
}
if($LASTEXITCODE -ne 0) { exit 11 }
Expand Down
6 changes: 5 additions & 1 deletion src/Datalust.Piggy/Datalust.Piggy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>A friendly PostgreSQL script runner in the spirit of DbUp.</Description>
<OutputType>exe</OutputType>
<OutputType>Exe</OutputType>
<VersionPrefix>2.0.0</VersionPrefix>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>piggy</AssemblyName>
Expand All @@ -28,6 +28,10 @@
<ToolCommandName>piggy</ToolCommandName>
<RollForward>Major</RollForward>
</PropertyGroup>

<ItemGroup Condition=" '$(OutputType)' != 'Exe' ">
<Compile Remove="Program.cs" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\asset\Piggy-Icon-128px.png" Pack="true" Visible="false" PackagePath="" />
Expand Down
26 changes: 8 additions & 18 deletions src/Datalust.Piggy/Program.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
using Autofac;
using Datalust.Piggy;
using Datalust.Piggy.Cli;
using Serilog;

namespace Datalust.Piggy
{
class Program
{
static int Main(string[] args)
{
var builder = new ContainerBuilder();
builder.RegisterModule<PiggyModule>();
var builder = new ContainerBuilder();
builder.RegisterModule<PiggyModule>();

using (var container = builder.Build())
{
var clh = container.Resolve<CommandLineHost>();
var exit = clh.Run(args);
Log.CloseAndFlush();
return exit;
}
}
}
}
await using var container = builder.Build();
var commandLineHost = container.Resolve<CommandLineHost>();
var exit = commandLineHost.Run(args);
await Log.CloseAndFlushAsync();
return exit;

0 comments on commit ac2e84e

Please sign in to comment.