mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2025-06-27 05:23:13 +00:00
Added Records
This commit is contained in:
BIN
Esiur/Tools/Esiur.psd1
Normal file
BIN
Esiur/Tools/Esiur.psd1
Normal file
Binary file not shown.
115
Esiur/Tools/Esiur.psm1
Normal file
115
Esiur/Tools/Esiur.psm1
Normal file
@ -0,0 +1,115 @@
|
||||
function Get-Template($url, $dir, $username, $password)
|
||||
{
|
||||
|
||||
$lib = Resolve-Path -Path "$($PSScriptRoot)\..\lib\netstandard2.0\Esiur.dll"
|
||||
#write-host "Lib is at $($lib)"
|
||||
|
||||
$assembly = [Reflection.Assembly]::LoadFile($lib)
|
||||
$tempPath = [Esiur.Proxy.TemplateGenerator]::GetTemplate($url, $dir, $username,$password);
|
||||
|
||||
$startupProject = GetStartupProject
|
||||
|
||||
$activeConfiguration = $startupProject.ConfigurationManager.ActiveConfiguration
|
||||
if ($activeConfiguration -eq $null)
|
||||
{
|
||||
throw "Unable to read project configuration settings of project '$($startupProject.ProjectName)' for the " +
|
||||
'active solution configuration. Try closing Package Manager Console and restarting Visual Studio. If the ' +
|
||||
'problem persists, use Help > Send Feedback > Report a Problem.'
|
||||
}
|
||||
|
||||
|
||||
$startupProject.ProjectItems.AddFromDirectory($tempPath) | Out-Null
|
||||
}
|
||||
|
||||
function GetStartupProject($name, $fallbackProject)
|
||||
{
|
||||
if ($name)
|
||||
{
|
||||
return Get-Project $name
|
||||
}
|
||||
|
||||
$startupProjectPaths = $DTE.Solution.SolutionBuild.StartupProjects
|
||||
if ($startupProjectPaths)
|
||||
{
|
||||
if ($startupProjectPaths.Length -eq 1)
|
||||
{
|
||||
$startupProjectPath = $startupProjectPaths[0]
|
||||
if (![IO.Path]::IsPathRooted($startupProjectPath))
|
||||
{
|
||||
$solutionPath = Split-Path (GetProperty $DTE.Solution.Properties 'Path')
|
||||
$startupProjectPath = [IO.Path]::GetFullPath((Join-Path $solutionPath $startupProjectPath))
|
||||
}
|
||||
|
||||
$startupProject = GetSolutionProjects | ?{
|
||||
try
|
||||
{
|
||||
$fullName = $_.FullName
|
||||
}
|
||||
catch [NotImplementedException]
|
||||
{
|
||||
return $false
|
||||
}
|
||||
|
||||
if ($fullName -and $fullName.EndsWith('\'))
|
||||
{
|
||||
$fullName = $fullName.Substring(0, $fullName.Length - 1)
|
||||
}
|
||||
|
||||
return $fullName -eq $startupProjectPath
|
||||
}
|
||||
if ($startupProject)
|
||||
{
|
||||
return $startupProject
|
||||
}
|
||||
|
||||
Write-Warning "Unable to resolve startup project '$startupProjectPath'."
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Warning 'Multiple startup projects set.'
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Warning 'No startup project set.'
|
||||
}
|
||||
|
||||
Write-Warning "Using project '$($fallbackProject.ProjectName)' as the startup project."
|
||||
|
||||
return $fallbackProject
|
||||
}
|
||||
|
||||
function GetProperty($properties, $propertyName)
|
||||
{
|
||||
try
|
||||
{
|
||||
return $properties.Item($propertyName).Value
|
||||
}
|
||||
catch
|
||||
{
|
||||
return $null
|
||||
}
|
||||
}
|
||||
|
||||
function GetSolutionProjects()
|
||||
{
|
||||
$projects = New-Object 'System.Collections.Stack'
|
||||
|
||||
$DTE.Solution.Projects | %{
|
||||
$projects.Push($_)
|
||||
}
|
||||
|
||||
while ($projects.Count)
|
||||
{
|
||||
$project = $projects.Pop();
|
||||
|
||||
<# yield return #> $project
|
||||
|
||||
if ($project.ProjectItems)
|
||||
{
|
||||
$project.ProjectItems | ?{ $_.SubProject } | %{
|
||||
$projects.Push($_.SubProject)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
36
Esiur/Tools/init.ps1
Normal file
36
Esiur/Tools/init.ps1
Normal file
@ -0,0 +1,36 @@
|
||||
|
||||
param($installPath, $toolsPath, $package, $project)
|
||||
|
||||
# NB: Not set for scripts in PowerShell 2.0
|
||||
if (!$PSScriptRoot)
|
||||
{
|
||||
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
|
||||
}
|
||||
|
||||
if ($PSVersionTable.PSVersion -lt '3.0')
|
||||
{
|
||||
# Import a "dummy" module that contains matching functions that throw on PS2
|
||||
Import-Module (Join-Path $PSScriptRoot 'Esiur.psd1') -DisableNameChecking
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
$importedModule = Get-Module 'Esiur'
|
||||
$moduleToImport = Test-ModuleManifest (Join-Path $PSScriptRoot 'Esiur.psd1')
|
||||
$import = $true
|
||||
if ($importedModule)
|
||||
{
|
||||
if ($importedModule.Version -le $moduleToImport.Version)
|
||||
{
|
||||
Remove-Module 'Esiur'
|
||||
}
|
||||
else
|
||||
{
|
||||
$import = $false
|
||||
}
|
||||
}
|
||||
|
||||
if ($import)
|
||||
{
|
||||
Import-Module $moduleToImport -DisableNameChecking
|
||||
}
|
Reference in New Issue
Block a user