feat(git-provider): add Sqlite to PowershellModule
- add CopyLocalLockFileAssemblies to PowershellModule.csproj - add postbuild script to copy Sqlite files and remove unneeded files in debug output - add sqlite-net-pcl 1.11.285
This commit is contained in:
parent
830ae2c560
commit
6193d30029
5 changed files with 73 additions and 32 deletions
|
|
@ -4,6 +4,7 @@
|
|||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.8.1" />
|
||||
<PackageVersion Include="sqlite-net-pcl" Version="1.11.285" />
|
||||
<PackageVersion Include="System.IO.Packaging" Version="10.0.10" />
|
||||
<PackageVersion Include="System.Security.Cryptography.Xml" Version="10.0.10" />
|
||||
<PackageVersion Include="Microsoft.PowerShell.SDK" Version="7.6.4" />
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Management.Automation;
|
||||
using System.Management.Automation.Provider;
|
||||
|
||||
|
|
@ -67,34 +66,3 @@ public class GitProvider : NavigationCmdletProvider
|
|||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
[Cmdlet(VerbsCommon.New, Noun)]
|
||||
public class RegisterGitRepo : PSCmdlet
|
||||
{
|
||||
private const string Noun = "GitRepo";
|
||||
|
||||
[Parameter(
|
||||
Mandatory = true,
|
||||
Position = 0,
|
||||
ValueFromPipeline = true,
|
||||
HelpMessage = "Reference name for the repo")]
|
||||
public string Name { get; set; }
|
||||
|
||||
protected override void BeginProcessing()
|
||||
{
|
||||
var pwd = this.SessionState.Path.CurrentLocation.Path;
|
||||
WriteObject("Checking if current directory is a git repository...");
|
||||
var ps = new ProcessStartInfo( //$"git -C \"{pwd}\" rev-parse --show-toplevel")
|
||||
"git", ["rev-parse", "--show-toplevel"])
|
||||
{
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
WorkingDirectory = pwd
|
||||
};
|
||||
var a = Process.Start(ps);
|
||||
Console.WriteLine(a.StandardOutput.ReadToEnd());
|
||||
Console.WriteLine(a.StandardError.ReadToEnd());
|
||||
|
||||
base.BeginProcessing();
|
||||
}
|
||||
}
|
||||
39
src/PowershellModule/Git/NewGitRepoCommand.cs
Normal file
39
src/PowershellModule/Git/NewGitRepoCommand.cs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Management.Automation;
|
||||
using SQLite;
|
||||
|
||||
namespace PowershellModule.Git;
|
||||
|
||||
[Cmdlet(VerbsCommon.New, Noun)]
|
||||
public class NewGitRepoCommand : PSCmdlet
|
||||
{
|
||||
private const string Noun = "GitRepo";
|
||||
|
||||
[Parameter(
|
||||
Mandatory = true,
|
||||
Position = 0,
|
||||
ValueFromPipeline = true,
|
||||
HelpMessage = "Reference name for the repo")]
|
||||
public string Name { get; set; }
|
||||
|
||||
protected override void BeginProcessing()
|
||||
{
|
||||
using var conn = new SQLiteConnection("./test.db");
|
||||
|
||||
var pwd = this.SessionState.Path.CurrentLocation.Path;
|
||||
WriteObject("Checking if current directory is a git repository...");
|
||||
var ps = new ProcessStartInfo( //$"git -C \"{pwd}\" rev-parse --show-toplevel")
|
||||
"git", ["rev-parse", "--show-toplevel"])
|
||||
{
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
WorkingDirectory = pwd
|
||||
};
|
||||
var a = Process.Start(ps);
|
||||
Console.WriteLine(a.StandardOutput.ReadToEnd());
|
||||
Console.WriteLine(a.StandardError.ReadToEnd());
|
||||
|
||||
base.BeginProcessing();
|
||||
}
|
||||
}
|
||||
27
src/PowershellModule/PostBuild.ps1
Normal file
27
src/PowershellModule/PostBuild.ps1
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Removes all non-core files from build output
|
||||
#>
|
||||
param(
|
||||
[Parameter(ValueFromPipeline = $true, Position = 0, Mandatory = $true)]
|
||||
$targetDir
|
||||
)
|
||||
|
||||
$nativeSqliteDllLocation = "$( $targetDir )runtimes\win-x64\native\e_sqlite3.dll";
|
||||
|
||||
if ($false -eq (Test-Path $nativeSqliteDllLocation))
|
||||
{
|
||||
Write-Error "POST BUILD FAILED: Unable to locate $nativeSqliteDllLocation"
|
||||
}
|
||||
|
||||
Write-Host "Copying '$nativeSqliteDllLocation' to '$targetDir'"
|
||||
Copy-Item -Path $nativeSqliteDllLocation -Destination $targetDir
|
||||
|
||||
# Because we use CopyLocalLockFileAssemblies Files that are needed for the module
|
||||
$allowList = @(
|
||||
"ModuleCore*"
|
||||
"PowershellModule*"
|
||||
"*SQLite*"
|
||||
)
|
||||
Write-Host "Removing all non-module required files from '$targetDir'"
|
||||
Get-ChildItem -Path $targetDir -exclude $allowList | Remove-Item -Recurse
|
||||
|
|
@ -5,16 +5,22 @@
|
|||
<AssemblyName>PowershellModule</AssemblyName>
|
||||
<LangVersion>latestmajor</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="PowerShellStandard.Library" >
|
||||
<PrivateAssets>All</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="sqlite-net-pcl" />
|
||||
<PackageReference Include="System.Management.Automation" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ModuleCore\ModuleCore.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="pwsh.exe -file "$(ProjectDir)PostBuild.ps1" $(TargetDir)" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
|
|
|||
Loading…
Reference in a new issue