From e41fa28ae6894cf1f34c6a37b2918bc3cf8629cc Mon Sep 17 00:00:00 2001 From: Suman Tokuri Date: Tue, 13 Dec 2022 21:50:37 +0530 Subject: [PATCH 1/4] Fixed Debug build dependencies --- build/Build-Debug.ps1 | 8 ++++++-- src/Commands/PnP.PowerShell.csproj | 11 ++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/build/Build-Debug.ps1 b/build/Build-Debug.ps1 index 737879740..bdbc0df92 100644 --- a/build/Build-Debug.ps1 +++ b/build/Build-Debug.ps1 @@ -53,7 +53,9 @@ if ($LocalPnPFramework) { $pnpFrameworkAssembly = Join-Path $PSScriptRoot -ChildPath "..\..\pnpframework\src\lib\PnP.Framework\bin\Debug\netstandard2.0\PnP.Framework.dll" $pnpFrameworkAssembly = [System.IO.Path]::GetFullPath($pnpFrameworkAssembly) if (Test-Path $pnpFrameworkAssembly -PathType Leaf) { - $buildCmd += " -p:PnPFrameworkPath=`"..\..\..\pnpframework\src\lib\`"" + $pnpFrameworkPath = $pnpFrameworkAssembly.Substring(0, $pnpFrameworkAssembly.IndexOf("PnP.Framework")) + Write-Host -Message "PnPFrameworkPath: $pnpFrameworkPath" + $buildCmd += " -p:PnPFrameworkPath=`"$pnpFrameworkPath`"" } else { $localFolder = Join-Path $PSScriptRoot -ChildPath "..\..\pnpframework" @@ -66,7 +68,9 @@ if ($LocalPnPCore) { $pnpCoreAssembly = Join-Path $PSScriptRoot -ChildPath "..\..\pnpcore\src\sdk\PnP.Core\bin\Debug\netstandard2.0\PnP.Core.dll" $pnpCoreAssembly = [System.IO.Path]::GetFullPath($pnpCoreAssembly) if (Test-Path $pnpCoreAssembly -PathType Leaf) { - $buildCmd += " -p:PnPCoreSdkPath=`"..\..\..\pnpcore\src\sdk\`"" + $pnpCoreSdkPath = $pnpCoreAssembly.Substring(0, $pnpCoreAssembly.IndexOf("PnP.Core")) + Write-Host -Message "PnPCoreSdkPath: $pnpCoreSdkPath" + $buildCmd += " -p:PnPCoreSdkPath=`"$pnpCoreSdkPath`"" } else { $localFolder = Join-Path $PSScriptRoot -ChildPath "..\..\pnpcore" diff --git a/src/Commands/PnP.PowerShell.csproj b/src/Commands/PnP.PowerShell.csproj index b7b2e4d40..066df5825 100644 --- a/src/Commands/PnP.PowerShell.csproj +++ b/src/Commands/PnP.PowerShell.csproj @@ -68,14 +68,11 @@ - + + - - - - + + From df7745955976d47f7da992f14e9d98618f01fd92 Mon Sep 17 00:00:00 2001 From: Suman Tokuri Date: Thu, 15 Dec 2022 16:45:27 +0530 Subject: [PATCH 2/4] Added FileStreamOptions when LogFile is specified --- src/Commands/Base/SetTraceLog.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Commands/Base/SetTraceLog.cs b/src/Commands/Base/SetTraceLog.cs index d10c0706b..d252b7d2d 100644 --- a/src/Commands/Base/SetTraceLog.cs +++ b/src/Commands/Base/SetTraceLog.cs @@ -2,6 +2,7 @@ using System; using System.Diagnostics; using System.Management.Automation; +using System.IO; namespace PnP.PowerShell.Commands.Base { @@ -58,11 +59,19 @@ protected override void ProcessRecord() { LogFile = System.IO.Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, LogFile); } + Console.WriteLine("LogFile path is : " + LogFile); // Create DelimitedListTraceListener in case Delimiter parameter has been specified, if not create TextWritterTraceListener +#if !NETFRAMEWORK + var fileStreamOptions = new FileStreamOptions { Mode = FileMode.Append, BufferSize = AutoFlush ? 0 : 4096, Access = FileAccess.Write, Options = AutoFlush ? FileOptions.WriteThrough : FileOptions.None }; + var fileStream = File.Open(LogFile, fileStreamOptions); + TraceListener listener = !string.IsNullOrEmpty(Delimiter) ? + new DelimitedListTraceListener(fileStream) { Delimiter = Delimiter, TraceOutputOptions = TraceOptions.DateTime } : + new TextWriterTraceListener(fileStream); +#else TraceListener listener = !string.IsNullOrEmpty(Delimiter) ? new DelimitedListTraceListener(LogFile) { Delimiter = Delimiter, TraceOutputOptions = TraceOptions.DateTime } : new TextWriterTraceListener(LogFile); - +#endif listener.Name = FileListenername; Trace.Listeners.Add(listener); PnP.Framework.Diagnostics.Log.LogLevel = Level; From b253a93af0ad21689b7bdaf22cbc8f2a8e975b2a Mon Sep 17 00:00:00 2001 From: Suman Tokuri Date: Fri, 16 Dec 2022 23:21:04 +0530 Subject: [PATCH 3/4] Use FileStreams while creating pnp template to reduce memory usage --- src/Commands/Provisioning/Site/GetSiteTemplate.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Commands/Provisioning/Site/GetSiteTemplate.cs b/src/Commands/Provisioning/Site/GetSiteTemplate.cs index 573d73a3f..09d2ee76d 100644 --- a/src/Commands/Provisioning/Site/GetSiteTemplate.cs +++ b/src/Commands/Provisioning/Site/GetSiteTemplate.cs @@ -120,6 +120,12 @@ public class GetSiteTemplate : PnPWebCmdlet [Parameter(Mandatory = false)] public ExtractConfigurationPipeBind Configuration; + [Parameter(Mandatory = false)] + public SwitchParameter UseFileStreams; + + [Parameter(Mandatory = false, Position = 0)] + public string PnPFilesPath; + protected override void ExecuteCmdlet() { ExtractConfiguration extractConfiguration = null; @@ -201,7 +207,7 @@ private void ExtractTemplate(XMLPnPSchemaVersion schema, string path, string pac var fileSystemConnector = new FileSystemConnector(path, ""); if (extension == ".pnp") { - creationInformation.FileConnector = new OpenXMLConnector(packageName, fileSystemConnector); + creationInformation.FileConnector = new OpenXMLConnector(packageName, fileSystemConnector, null, null, null, UseFileStreams, PnPFilesPath); } else if (extension == ".md") { From 34ba2155d4758386ef69861dc21dc573a19044ed Mon Sep 17 00:00:00 2001 From: Suman Tokuri Date: Fri, 16 Dec 2022 23:21:04 +0530 Subject: [PATCH 4/4] Use FileStreams while creating pnp template to reduce memory usage --- src/Commands/Provisioning/Site/GetSiteTemplate.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Commands/Provisioning/Site/GetSiteTemplate.cs b/src/Commands/Provisioning/Site/GetSiteTemplate.cs index 09d2ee76d..a7110b8aa 100644 --- a/src/Commands/Provisioning/Site/GetSiteTemplate.cs +++ b/src/Commands/Provisioning/Site/GetSiteTemplate.cs @@ -124,7 +124,7 @@ public class GetSiteTemplate : PnPWebCmdlet public SwitchParameter UseFileStreams; [Parameter(Mandatory = false, Position = 0)] - public string PnPFilesPath; + public string PnPTempFilesPath; protected override void ExecuteCmdlet() { @@ -207,7 +207,7 @@ private void ExtractTemplate(XMLPnPSchemaVersion schema, string path, string pac var fileSystemConnector = new FileSystemConnector(path, ""); if (extension == ".pnp") { - creationInformation.FileConnector = new OpenXMLConnector(packageName, fileSystemConnector, null, null, null, UseFileStreams, PnPFilesPath); + creationInformation.FileConnector = new OpenXMLConnector(packageName, fileSystemConnector, null, null, null, UseFileStreams, PnPTempFilesPath); } else if (extension == ".md") {