Skip to content

Commit ca2658b

Browse files
authored
Move the enable long path into dotnet installation (#329)
* Move the enable long path into dotnet installation * remove version action * change version
1 parent f9fe84b commit ca2658b

File tree

9 files changed

+27
-76
lines changed

9 files changed

+27
-76
lines changed

.github/workflows/increment-version.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

.pipelines/azure-pipelines-linux.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ resources:
1616
options: --entrypoint=""
1717

1818
variables:
19-
VcVersion : 1.14.34
19+
VcVersion : 1.0.0
2020
ROOT: $(Build.SourcesDirectory)
2121
CDP_DEFINITION_BUILD_COUNT: $[counter('', 0)] # needed for onebranch.pipeline.version task https://aka.ms/obpipelines/versioning
2222
ENABLE_PRS_DELAYSIGN: 1
@@ -43,7 +43,7 @@ stages:
4343
version=$(Build.SourcesDirectory)/VERSION
4444
4545
# Set the file content as a pipeline variable
46-
echo "##vso[task.setvariable variable=VcVersion;isOutput=true]$version"
46+
echo "##vso[task.setvariable variable=VcVersion]$version"
4747
displayName: 'Set VC Version'
4848
4949
- script: chmod -R +x $(Build.SourcesDirectory)

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.14.35
1+
1.14.36

build.cmd

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ if /i "%~1" == "/?" Goto :Usage
66
if /i "%~1" == "-?" Goto :Usage
77
if /i "%~1" == "--help" Goto :Usage
88

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

19+
REM Default version to the VERSION file but append -alpha for manual builds
1720
if /i "%VCBuildVersion%" == "" (
18-
set VCBuildVersion=0.0.1.0
21+
set /p VCBuildVersion=<VERSION
1922
)
2023

2124
set VCSolutionDir=%~dp0src\VirtualClient

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if [ -n "$1" ]; then
55
fi
66

77
if [ -z "$VCBuildVersion" ]; then
8-
VCBuildVersion="0.0.1"
8+
VCBuildVersion=$(cat VERSION)
99
fi
1010

1111
while [[ "$#" -gt 0 ]]; do

increment-version.sh

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/VirtualClient/VirtualClient.Core/SystemManagement.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace VirtualClient
1111
using System.Linq;
1212
using System.Net;
1313
using System.Runtime.InteropServices;
14+
using System.Security.Principal;
1415
using System.Text.RegularExpressions;
1516
using System.Threading;
1617
using System.Threading.Tasks;
@@ -248,6 +249,7 @@ public bool IsLocalIPAddress(string ipAddress)
248249
/// <summary>
249250
/// Overwrite the default of 260 char in windows file path length to 32,767.
250251
/// https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry
252+
/// Does not throw if doesn't have priviledge
251253
/// </summary>
252254
public void EnableLongPathInWindows()
253255
{
@@ -258,8 +260,16 @@ public void EnableLongPathInWindows()
258260
// Name of the DWORD value
259261
const string valueName = "LongPathsEnabled";
260262

261-
// Set the value to enable long paths
262-
Registry.SetValue(keyPath, valueName, 1, RegistryValueKind.DWord);
263+
try
264+
{
265+
// Set the value to enable long paths
266+
Registry.SetValue(keyPath, valueName, 1, RegistryValueKind.DWord);
267+
}
268+
catch
269+
{
270+
// Does not throw if missing admin priviledge
271+
}
272+
263273
}
264274
}
265275

src/VirtualClient/VirtualClient.Dependencies/DotNet/DotNetInstallation.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class DotNetInstallation : VirtualClientComponent
2424
private const string WindowsInstallScriptName = "dotnet-install.ps1";
2525

2626
private string installDirectory;
27-
private ISystemManagement systemManager;
27+
private ISystemManagement systemManagement;
2828
private IFileSystem fileSystem;
2929

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

4343
this.installDirectory = this.PlatformSpecifics.Combine(this.PlatformSpecifics.PackagesDirectory, "dotnet");
@@ -62,6 +62,8 @@ public string DotNetVersion
6262
/// </summary>
6363
protected override async Task ExecuteAsync(EventContext telemetryContext, CancellationToken cancellationToken)
6464
{
65+
this.systemManagement.EnableLongPathInWindows();
66+
6567
if (!this.fileSystem.Directory.Exists(this.installDirectory))
6668
{
6769
this.fileSystem.Directory.CreateDirectory(this.installDirectory);
@@ -74,7 +76,7 @@ protected override async Task ExecuteAsync(EventContext telemetryContext, Cancel
7476

7577
if (this.Platform == PlatformID.Unix)
7678
{
77-
await this.systemManager.MakeFileExecutableAsync(destinyFile, this.Platform, cancellationToken).ConfigureAwait(false);
79+
await this.systemManagement.MakeFileExecutableAsync(destinyFile, this.Platform, cancellationToken).ConfigureAwait(false);
7880
await this.ExecuteCommandAsync(destinyFile, this.GetInstallArgument(), this.installDirectory, telemetryContext, cancellationToken).ConfigureAwait(false);
7981
}
8082
else
@@ -83,7 +85,7 @@ protected override async Task ExecuteAsync(EventContext telemetryContext, Cancel
8385
}
8486

8587
DependencyPath dotnetPackage = new DependencyPath(this.PackageName, this.installDirectory, "DotNet SDK", this.DotNetVersion);
86-
await this.systemManager.PackageManager.RegisterPackageAsync(dotnetPackage, cancellationToken).ConfigureAwait(false);
88+
await this.systemManagement.PackageManager.RegisterPackageAsync(dotnetPackage, cancellationToken).ConfigureAwait(false);
8789
}
8890

8991
private string GetInstallArgument()
@@ -107,7 +109,7 @@ private string GetInstallArgument()
107109
private async Task ExecuteCommandAsync(string pathToExe, string commandLineArguments, string workingDirectory, EventContext telemetryContext, CancellationToken cancellationToken)
108110
{
109111
EventContext relatedContext = telemetryContext.Clone();
110-
using (IProcessProxy process = this.systemManager.ProcessManager.CreateElevatedProcess(this.Platform, pathToExe, commandLineArguments, workingDirectory))
112+
using (IProcessProxy process = this.systemManagement.ProcessManager.CreateElevatedProcess(this.Platform, pathToExe, commandLineArguments, workingDirectory))
111113
{
112114
this.CleanupTasks.Add(() => process.SafeKill());
113115
this.Logger.LogTraceMessage($"Executing process '{pathToExe}' '{commandLineArguments}' at directory '{workingDirectory}'.", EventContext.Persisted());

src/VirtualClient/VirtualClient.Main/RunProfileCommand.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,6 @@ protected override IServiceCollection InitializeDependencies(string[] args)
302302
platformSpecifics.CpuArchitecture,
303303
logger);
304304

305-
systemManagement.EnableLongPathInWindows();
306-
307305
IApiManager apiManager = new ApiManager(systemManagement.FirewallManager);
308306

309307
// 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

0 commit comments

Comments
 (0)