Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/src/Cake.Powershell.Tests/bin/Debug/net5.0/Cake.Powershell.Tests.dll",
"args": [],
"cwd": "${workspaceFolder}/src/Cake.Powershell.Tests",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
42 changes: 42 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/src/Cake.Powershell.Tests/Cake.Powershell.Tests.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/src/Cake.Powershell.Tests/Cake.Powershell.Tests.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"${workspaceFolder}/src/Cake.Powershell.Tests/Cake.Powershell.Tests.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
}
19 changes: 19 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml

trigger:
- main

pool:
vmImage: 'ubuntu-latest'

steps:
- script: echo Hello, world!
displayName: 'Run a one-line script'

- script: |
echo Add other tasks to build, test, and deploy your project.
echo See https://aka.ms/yaml
displayName: 'Run a multi-line script'
45 changes: 45 additions & 0 deletions nuget.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="Cake.Powershell" value="https://ra-cps-dev.pkgs.visualstudio.com/NEWS/_packagitging/Cake.Powershell/nuget/v3/index.json" />
<add key="DirectoryFileParserLibrary" value="https://ra-cps-dev.pkgs.visualstudio.com/_packaging/DirectoryFileParserLibrary/nuget/v3/index.json" />
<add key="ColocatedFeed" value="https://ra-cps-dev.pkgs.visualstudio.com/_packaging/CoLocatedAssemblyLoader/nuget/v3/index.json" />
<add key="WixBootstrapperApplicationData" value="https://ra-cps-dev.pkgs.visualstudio.com/_packaging/WixBootstrapperApplicationData/nuget/v3/index.json" />
<add key="NEWS_ACAD-Common" value="https://ra-cps-dev.pkgs.visualstudio.com/_packaging/NEWS_ACAD-Common/nuget/v3/index.json" />
<add key="NEWS_AutoCAD_DotNet_Library" value="https://ra-cps-dev.pkgs.visualstudio.com/_packaging/NEWS_AutoCAD_DotNet_Library/nuget/v3/index.json" />
<add key="VB6_CakeBuildAddin" value="https://ra-cps-dev.pkgs.visualstudio.com/_packaging/VB6_CakeBuildAddin/nuget/v3/index.json" />
<add key="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\" />
<add key="WpfWrappingPanel" value="https://ra-cps-dev.pkgs.visualstudio.com/_packaging/WpfWrappingPanel/nuget/v3/index.json" />
<add key="WpfTreeViewList" value="https://ra-cps-dev.pkgs.visualstudio.com/_packaging/WpfTreeViewListControl/nuget/v3/index.json" />
<add key="WpfListViewCustomControl" value="https://ra-cps-dev.pkgs.visualstudio.com/_packaging/WpfListViewCustomControl/nuget/v3/index.json" />
<add key="SerilogTraceHelper" value="https://ra-cps-dev.pkgs.visualstudio.com/_packaging/SerilogLogTraceHelper/nuget/v3/index.json" />
</packageSources>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<bindingRedirects>
<add key="skip" value="False" />
</bindingRedirects>
<packageManagement>
<add key="format" value="1" />
<add key="disabled" value="False" />
</packageManagement>
<disabledPackageSources>
<!-- -->
<add key="Ra-Cps-Dev VSTS Feed" value="true" />
<add key="DirectoryFileParserLibrary" value="true" />
<add key="ColocatedFeed" value="true" />
<add key="WixBootstrapperApplicationData" value="true" />
<add key="NEWS_ACAD-Common" value="true" />
<add key="NEWS_AutoCAD_DotNet_Library" value="true" />
<add key="VB6_CakeBuildAddin" value="true" />
<add key="Microsoft Visual Studio Offline Packages" value="true" />
<add key="WpfWrappingPanel" value="true" />
<add key="WpfTreeViewList" value="true" />
<add key="WpfListViewCustomControl" value="true" />
<add key="SerilogTraceHelper" value="true" />

</disabledPackageSources>
</configuration>
16 changes: 8 additions & 8 deletions src/Cake.Powershell.Tests/Cake.Powershell.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<PackageId>Cake.Powershell.Tests</PackageId>
<OutputType>Library</OutputType>

<TargetFrameworks>net46;netcoreapp3.1;net5.0</TargetFrameworks>
<TargetFrameworks>net60</TargetFrameworks>

<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
Expand All @@ -19,20 +19,20 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Cake.Core" Version="1.0.0" />
<PackageReference Include="Cake.Testing" Version="1.0.0" />
<PackageReference Include="Cake.Core" Version="1.0.0-rc0002" />
<PackageReference Include="Cake.Testing" Version="1.0.0-rc0002" />

<PackageReference Include="Microsoft.PowerShell.5.ReferenceAssemblies" Version="1.1.0" Condition="'$(TargetFramework)' == 'net46'" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.0.5" Condition="'$(TargetFramework)' == 'netcoreapp3.1'" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.1.2" Condition="'$(TargetFramework)' == 'net5.0'" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.2.0-preview.2" />
<PackageReference Include="Microsoft.WSMan.Management" Version="7.2.0-preview.2" />

<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit" Version="2.4.2-pre.12" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Shouldly" Version="4.0.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="XunitXml.TestLogger" Version="3.0.62" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.0-preview-20210106-01" />
<PackageReference Include="XunitXml.TestLogger" Version="2.1.26" />
</ItemGroup>
</Project>
7 changes: 4 additions & 3 deletions src/Cake.Powershell/Aliases/PowershellAliases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Cake.Core.Annotations;

using System.Management.Automation;
using System.Threading.Tasks;
#endregion


Expand Down Expand Up @@ -109,7 +110,7 @@ public static Collection<PSObject> StartPowershellFile(this ICakeContext context
/// <param name="path">The temporary path to download the file to.</param>
/// <returns>A collection of powershell objects</returns>
[CakeMethodAlias]
public static Collection<PSObject> StartPowershellDownload(this ICakeContext context, Uri uri, FilePath path)
public static Task<Collection<PSObject>> StartPowershellDownload(this ICakeContext context, Uri uri, FilePath path)
{
return new PowershellRunner(context.Environment, context.Log).Start(uri, path, new PowershellSettings());
}
Expand All @@ -123,7 +124,7 @@ public static Collection<PSObject> StartPowershellDownload(this ICakeContext con
/// <param name="arguments">The arguments to append.</param>
/// <returns>A collection of powershell objects</returns>
[CakeMethodAlias]
public static Collection<PSObject> StartPowershellDownload(this ICakeContext context, Uri uri, FilePath path, Action<ProcessArgumentBuilder> arguments)
public static Task<Collection<PSObject>> StartPowershellDownload(this ICakeContext context, Uri uri, FilePath path, Action<ProcessArgumentBuilder> arguments)
{
return new PowershellRunner(context.Environment, context.Log).Start(uri, path, new PowershellSettings().WithArguments(arguments));
}
Expand All @@ -137,7 +138,7 @@ public static Collection<PSObject> StartPowershellDownload(this ICakeContext con
/// <param name="settings">The information about the script to start.</param>
/// <returns>A collection of powershell objects</returns>
[CakeMethodAlias]
public static Collection<PSObject> StartPowershellDownload(this ICakeContext context, Uri uri, FilePath path, PowershellSettings settings)
public static Task<Collection<PSObject>> StartPowershellDownload(this ICakeContext context, Uri uri, FilePath path, PowershellSettings settings)
{
return new PowershellRunner(context.Environment, context.Log).Start(uri, path, settings);
}
Expand Down
14 changes: 8 additions & 6 deletions src/Cake.Powershell/Cake.Powershell.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<PackageId>Cake.Powershell</PackageId>
<OutputType>Library</OutputType>

<TargetFrameworks>net46;netcoreapp3.1;net5.0</TargetFrameworks>
<TargetFrameworks>net60;</TargetFrameworks>

<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
Expand All @@ -15,13 +15,15 @@
</PropertyGroup>

<PropertyGroup>
<DocumentationFile>bin\Debug\net46\Cake.Powershell.xml</DocumentationFile>
<DocumentationFile>bin\Debug\net50\Cake.Powershell.xml</DocumentationFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Cake.Core" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.PowerShell.5.ReferenceAssemblies" Version="1.1.0" Condition="'$(TargetFramework)' == 'net46'" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.0.5" Condition="'$(TargetFramework)' == 'netcoreapp3.1'" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.1.2" Condition="'$(TargetFramework)' == 'net5.0'" />
<PackageReference Include="Cake.Core" Version="1.0.0-rc0002" PrivateAssets="All" />
<PackageReference Include="Microsoft.Management.Infrastructure" Version="2.0.0" />
<PackageReference Include="Microsoft.Management.Infrastructure.Runtime.Win" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.1.0" />
<PackageReference Include="Microsoft.WSMan.Management" Version="7.1.0" />
</ItemGroup>
</Project>
7 changes: 6 additions & 1 deletion src/Cake.Powershell/Host/CakePSHostRawUserInterface.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#region Using Statements
using System;
using System.Management.Automation.Host;

using System.Runtime.Versioning;
using Cake.Core.Diagnostics;
#endregion

Expand Down Expand Up @@ -50,6 +50,7 @@ public override ConsoleColor BackgroundColor
/// Gets or sets the size of the host buffer. In this example the
/// buffer size is adapted from the Console buffer size members.
/// </summary>
[SupportedOSPlatform("windows")]
public override Size BufferSize
{
get { return new Size(Console.BufferWidth, Console.BufferHeight); }
Expand Down Expand Up @@ -91,6 +92,7 @@ public override Coordinates CursorPosition
/// the cursor size is taken directly from the Console.CursorSize
/// property.
/// </summary>
[SupportedOSPlatform("windows")]
public override int CursorSize
{
get { return Console.CursorSize; }
Expand Down Expand Up @@ -157,6 +159,7 @@ public override Size MaxWindowSize
/// uses the Console window position APIs to determine the returned
/// value of this property.
/// </summary>
[SupportedOSPlatform("windows")]
public override Coordinates WindowPosition
{
get { return new Coordinates(Console.WindowLeft, Console.WindowTop); }
Expand All @@ -181,6 +184,7 @@ public override Coordinates WindowPosition
/// uses the corresponding Console window size APIs to determine the
/// returned value of this property.
/// </summary>
[SupportedOSPlatform("windows")]
public override Size WindowSize
{
get { return new Size(Console.WindowWidth, Console.WindowHeight); }
Expand All @@ -204,6 +208,7 @@ public override Size WindowSize
/// Gets or sets the title of the displayed window. The example
/// maps the Console.Title property to the value of this property.
/// </summary>
[SupportedOSPlatform("windows")]
public override string WindowTitle
{
get
Expand Down
4 changes: 2 additions & 2 deletions src/Cake.Powershell/Interfaces/IPowershellRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Collections.ObjectModel;

using System.Management.Automation;

using System.Threading.Tasks;
using Cake.Core.IO;
#endregion

Expand Down Expand Up @@ -40,7 +40,7 @@ public interface IPowershellRunner
/// <param name="path">The temporary path to download the file to.</param>
/// <param name="settings">The information about the process to start.</param>
/// <returns>Powershell objects.</returns>
Collection<PSObject> Start(Uri uri, FilePath path, PowershellSettings settings);
Task<Collection<PSObject>> Start(Uri uri, FilePath path, PowershellSettings settings);
#endregion
}
}
19 changes: 13 additions & 6 deletions src/Cake.Powershell/Runner/PowershellRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
using System;
using System.Collections.ObjectModel;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
using System.Net;
using System.Net.Http;
using System.Threading;

using System.Threading.Tasks;
using Cake.Core;
using Cake.Core.Diagnostics;
using Cake.Core.IO;
Expand Down Expand Up @@ -145,7 +147,7 @@ public Collection<PSObject> Start(FilePath path, PowershellSettings settings)
/// <param name="path">The temporary path to download the file to.</param>
/// <param name="settings">The information about the process to start.</param>
/// <returns>Powershell objects.</returns>
public Collection<PSObject> Start(Uri uri, FilePath path, PowershellSettings settings)
public async Task<Collection<PSObject>> Start(Uri uri, FilePath path, PowershellSettings settings)
{
if (uri == null)
{
Expand All @@ -163,13 +165,18 @@ public Collection<PSObject> Start(Uri uri, FilePath path, PowershellSettings set

string prefix = settings.UseDotSourcing ? ". " : "&";
string fullPath = path.MakeAbsolute(settings.WorkingDirectory).FullPath;
string script = prefix + "\"" + fullPath + "\"";
string script = $"{prefix}\\{fullPath}\\temp.ps1";



//Download Script
WebClient client = new WebClient();
client.DownloadFile(uri, fullPath);
var client = new HttpClient();
using (var stream = await client.GetStreamAsync(uri).ConfigureAwait(false))
using (var fileStream = new FileStream(script, FileMode.CreateNew))
{
await stream.CopyToAsync(fileStream);
}


LogExecutingCommand(settings, script);

Expand All @@ -179,7 +186,7 @@ public Collection<PSObject> Start(Uri uri, FilePath path, PowershellSettings set
//Call
script = this.AppendArguments(script, settings.Arguments, false);

return this.Invoke(script, settings);
return await Task.FromResult(this.Invoke(script, settings));
}


Expand Down
8 changes: 4 additions & 4 deletions src/SolutionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
//------------------------------------------------------------------------------
using System.Reflection;

[assembly: AssemblyVersion("0.4.8")]
[assembly: AssemblyFileVersion("0.4.8")]
[assembly: AssemblyInformationalVersion("0.4.8")]
[assembly: AssemblyCopyright("Copyright (c) 2015 - 2021 Phillip Sharpe")]
[assembly: AssemblyVersion("1.0.1")]
[assembly: AssemblyFileVersion("1.0.1")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyCopyright("Copyright (c) 2015 - 2022 Phillip Sharpe")]