b0ee5db411
If there are shims packaged by convention in nupkg. Shim Repository will simply copy it to the right location. The query interface ToolPackageInstance will be in charge of finding the shim folder and filter the right RID. Shim Repository will pick the right file after the folder is located since Shim Repository knows the shim name and it also book keep the files at uninstallation. During development, due to the wrong adapter level. The mock duplicated too much logic. So, I corrected the abstraction level to lower (only create shim). And replaced the existing mock with a much smaller one without any atomic control and file move, copy logic. At the same time. The chmod, which is a IO action, causes problem during tests. So I added adapter layer to it and put it in Util.
38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
using Microsoft.DotNet.ShellShim;
|
|
using Microsoft.Extensions.EnvironmentAbstractions;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace Microsoft.DotNet.Tools.Tests.ComponentMocks
|
|
{
|
|
internal class AppHostShellShimMakerMock : IAppHostShellShimMaker
|
|
{
|
|
private static IFileSystem _fileSystem;
|
|
|
|
public AppHostShellShimMakerMock(IFileSystem fileSystem = null)
|
|
{
|
|
_fileSystem = fileSystem ?? new FileSystemWrapper();
|
|
}
|
|
|
|
public void CreateApphostShellShim(FilePath entryPoint, FilePath shimPath)
|
|
{
|
|
var shim = new FakeShim
|
|
{
|
|
Runner = "dotnet",
|
|
ExecutablePath = entryPoint.Value
|
|
};
|
|
|
|
_fileSystem.File.WriteAllText(
|
|
shimPath.Value,
|
|
JsonConvert.SerializeObject(shim));
|
|
}
|
|
|
|
public class FakeShim
|
|
{
|
|
public string Runner { get; set; }
|
|
public string ExecutablePath { get; set; }
|
|
}
|
|
}
|
|
}
|