Skip to content

Commit

Permalink
Move the enable long path into dotnet installation (#329)
Browse files Browse the repository at this point in the history
* Move the enable long path into dotnet installation

* remove version action

* change version
  • Loading branch information
yangpanMS authored May 30, 2024
1 parent f9fe84b commit ca2658b
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 76 deletions.
25 changes: 0 additions & 25 deletions .github/workflows/increment-version.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .pipelines/azure-pipelines-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ resources:
options: --entrypoint=""

variables:
VcVersion : 1.14.34
VcVersion : 1.0.0
ROOT: $(Build.SourcesDirectory)
CDP_DEFINITION_BUILD_COUNT: $[counter('', 0)] # needed for onebranch.pipeline.version task https://aka.ms/obpipelines/versioning
ENABLE_PRS_DELAYSIGN: 1
Expand All @@ -43,7 +43,7 @@ stages:
version=$(Build.SourcesDirectory)/VERSION
# Set the file content as a pipeline variable
echo "##vso[task.setvariable variable=VcVersion;isOutput=true]$version"
echo "##vso[task.setvariable variable=VcVersion]$version"
displayName: 'Set VC Version'
- script: chmod -R +x $(Build.SourcesDirectory)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.14.35
1.14.36
5 changes: 4 additions & 1 deletion build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ if /i "%~1" == "/?" Goto :Usage
if /i "%~1" == "-?" Goto :Usage
if /i "%~1" == "--help" Goto :Usage

set "VCBuildVersion="

REM The "VCBuildVersion" environment variable is referenced by the MSBuild processes during build.
REM All binaries will be compiled with this version (e.g. .dlls + .exes). The packaging process uses
REM the same environment variable to define the version of the NuGet package(s) produced. The build
Expand All @@ -14,8 +16,9 @@ if /i NOT "%~1" == "" (
set VCBuildVersion=%~1
)

REM Default version to the VERSION file but append -alpha for manual builds
if /i "%VCBuildVersion%" == "" (
set VCBuildVersion=0.0.1.0
set /p VCBuildVersion=<VERSION
)

set VCSolutionDir=%~dp0src\VirtualClient
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if [ -n "$1" ]; then
fi

if [ -z "$VCBuildVersion" ]; then
VCBuildVersion="0.0.1"
VCBuildVersion=$(cat VERSION)
fi

while [[ "$#" -gt 0 ]]; do
Expand Down
37 changes: 0 additions & 37 deletions increment-version.sh

This file was deleted.

14 changes: 12 additions & 2 deletions src/VirtualClient/VirtualClient.Core/SystemManagement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace VirtualClient
using System.Linq;
using System.Net;
using System.Runtime.InteropServices;
using System.Security.Principal;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -248,6 +249,7 @@ public bool IsLocalIPAddress(string ipAddress)
/// <summary>
/// Overwrite the default of 260 char in windows file path length to 32,767.
/// https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry
/// Does not throw if doesn't have priviledge
/// </summary>
public void EnableLongPathInWindows()
{
Expand All @@ -258,8 +260,16 @@ public void EnableLongPathInWindows()
// Name of the DWORD value
const string valueName = "LongPathsEnabled";

// Set the value to enable long paths
Registry.SetValue(keyPath, valueName, 1, RegistryValueKind.DWord);
try
{
// Set the value to enable long paths
Registry.SetValue(keyPath, valueName, 1, RegistryValueKind.DWord);
}
catch
{
// Does not throw if missing admin priviledge
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class DotNetInstallation : VirtualClientComponent
private const string WindowsInstallScriptName = "dotnet-install.ps1";

private string installDirectory;
private ISystemManagement systemManager;
private ISystemManagement systemManagement;
private IFileSystem fileSystem;

/// <summary>
Expand All @@ -37,7 +37,7 @@ public class DotNetInstallation : VirtualClientComponent
public DotNetInstallation(IServiceCollection dependencies, IDictionary<string, IConvertible> parameters = null)
: base(dependencies, parameters)
{
this.systemManager = this.Dependencies.GetService<ISystemManagement>();
this.systemManagement = this.Dependencies.GetService<ISystemManagement>();
this.fileSystem = this.Dependencies.GetService<IFileSystem>();

this.installDirectory = this.PlatformSpecifics.Combine(this.PlatformSpecifics.PackagesDirectory, "dotnet");
Expand All @@ -62,6 +62,8 @@ public string DotNetVersion
/// </summary>
protected override async Task ExecuteAsync(EventContext telemetryContext, CancellationToken cancellationToken)
{
this.systemManagement.EnableLongPathInWindows();

if (!this.fileSystem.Directory.Exists(this.installDirectory))
{
this.fileSystem.Directory.CreateDirectory(this.installDirectory);
Expand All @@ -74,7 +76,7 @@ protected override async Task ExecuteAsync(EventContext telemetryContext, Cancel

if (this.Platform == PlatformID.Unix)
{
await this.systemManager.MakeFileExecutableAsync(destinyFile, this.Platform, cancellationToken).ConfigureAwait(false);
await this.systemManagement.MakeFileExecutableAsync(destinyFile, this.Platform, cancellationToken).ConfigureAwait(false);
await this.ExecuteCommandAsync(destinyFile, this.GetInstallArgument(), this.installDirectory, telemetryContext, cancellationToken).ConfigureAwait(false);
}
else
Expand All @@ -83,7 +85,7 @@ protected override async Task ExecuteAsync(EventContext telemetryContext, Cancel
}

DependencyPath dotnetPackage = new DependencyPath(this.PackageName, this.installDirectory, "DotNet SDK", this.DotNetVersion);
await this.systemManager.PackageManager.RegisterPackageAsync(dotnetPackage, cancellationToken).ConfigureAwait(false);
await this.systemManagement.PackageManager.RegisterPackageAsync(dotnetPackage, cancellationToken).ConfigureAwait(false);
}

private string GetInstallArgument()
Expand All @@ -107,7 +109,7 @@ private string GetInstallArgument()
private async Task ExecuteCommandAsync(string pathToExe, string commandLineArguments, string workingDirectory, EventContext telemetryContext, CancellationToken cancellationToken)
{
EventContext relatedContext = telemetryContext.Clone();
using (IProcessProxy process = this.systemManager.ProcessManager.CreateElevatedProcess(this.Platform, pathToExe, commandLineArguments, workingDirectory))
using (IProcessProxy process = this.systemManagement.ProcessManager.CreateElevatedProcess(this.Platform, pathToExe, commandLineArguments, workingDirectory))
{
this.CleanupTasks.Add(() => process.SafeKill());
this.Logger.LogTraceMessage($"Executing process '{pathToExe}' '{commandLineArguments}' at directory '{workingDirectory}'.", EventContext.Persisted());
Expand Down
2 changes: 0 additions & 2 deletions src/VirtualClient/VirtualClient.Main/RunProfileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,6 @@ protected override IServiceCollection InitializeDependencies(string[] args)
platformSpecifics.CpuArchitecture,
logger);

systemManagement.EnableLongPathInWindows();

IApiManager apiManager = new ApiManager(systemManagement.FirewallManager);

// Note that a bug was found in the version of "lshw" (B.02.18) that is installed on some Ubuntu images. The bug causes the
Expand Down

0 comments on commit ca2658b

Please sign in to comment.