From 97817b0ca2cf70e8136542c5e5e1b6b3592c607f Mon Sep 17 00:00:00 2001 From: William Li Date: Sun, 9 Sep 2018 21:16:11 -0700 Subject: [PATCH] Fix merge --- .../general/signing-global-tool-packages.md | 60 ------- .../general/tool-nuget-package-format.md | 29 ---- .../dotnet-dependency-tool-invoker.csproj | 5 +- .../MultitargetedCS/MultitargetedCS.csproj | 8 - .../MultitargetedCS/Program.cs | 12 -- .../MultitargetedFS/MultitargetedFS.fsproj | 12 -- .../MultitargetedFS/Program.fs | 8 - .../MultitargetedVB/MultitargetedVB.vbproj | 9 - .../MultitargetedVB/Program.vb | 7 - ...estAppsWithSlnAndMultitargetedProjects.sln | 18 -- build/BundledTemplates.props | 4 +- build/DependencyVersions.props | 3 +- build/run-build.ps1 | 0 run-build.ps1 | 2 +- .../Interop.cs | 135 --------------- .../NETCoreSdkResolver.cs | 76 --------- .../VSSettings.cs | 155 ------------------ src/dotnet/ToolPackage/PackageLocation.cs | 23 --- .../ToolCommandRestorePassThroughOptions.cs | 36 ---- 19 files changed, 5 insertions(+), 597 deletions(-) delete mode 100644 Documentation/general/signing-global-tool-packages.md delete mode 100644 Documentation/general/tool-nuget-package-format.md delete mode 100644 TestAssets/TestProjects/TestAppsWithSlnAndMultitargetedProjects/MultitargetedCS/MultitargetedCS.csproj delete mode 100644 TestAssets/TestProjects/TestAppsWithSlnAndMultitargetedProjects/MultitargetedCS/Program.cs delete mode 100644 TestAssets/TestProjects/TestAppsWithSlnAndMultitargetedProjects/MultitargetedFS/MultitargetedFS.fsproj delete mode 100644 TestAssets/TestProjects/TestAppsWithSlnAndMultitargetedProjects/MultitargetedFS/Program.fs delete mode 100644 TestAssets/TestProjects/TestAppsWithSlnAndMultitargetedProjects/MultitargetedVB/MultitargetedVB.vbproj delete mode 100644 TestAssets/TestProjects/TestAppsWithSlnAndMultitargetedProjects/MultitargetedVB/Program.vb delete mode 100644 TestAssets/TestProjects/TestAppsWithSlnAndMultitargetedProjects/TestAppsWithSlnAndMultitargetedProjects.sln create mode 100644 build/run-build.ps1 delete mode 100644 src/Microsoft.DotNet.MSBuildSdkResolver/Interop.cs delete mode 100644 src/Microsoft.DotNet.MSBuildSdkResolver/NETCoreSdkResolver.cs delete mode 100644 src/Microsoft.DotNet.MSBuildSdkResolver/VSSettings.cs delete mode 100644 src/dotnet/ToolPackage/PackageLocation.cs delete mode 100644 src/dotnet/commands/dotnet-tool/ToolCommandRestorePassThroughOptions.cs diff --git a/Documentation/general/signing-global-tool-packages.md b/Documentation/general/signing-global-tool-packages.md deleted file mode 100644 index 5ecb910a1..000000000 --- a/Documentation/general/signing-global-tool-packages.md +++ /dev/null @@ -1,60 +0,0 @@ -Signing .NET Core Global Tool Packages -=============================== - -To create a signed package for your Dotnet Tool, you will need to create a signed shim. If a shim is found in the nupkg during `dotnet tool install`, it is used instead of creating one on consumer's machine. - -To create a signed shim, you need to add the following extra property in you project file: - -``` - [list of RIDs] -``` - -When this property is set, `dotnet pack` will generate a shim in the package (nupkg). Assuming all other other content is signed, after you sign the shim you can sign the nupkg. - -Example: -```xml - - - - Exe - netcoreapp2.1 - true - win-x64;win-x86;osx-x64 - - -``` - -The result nupkg will have packaged shim included. Of course `dotnet pack` does not sign the shim or the package. The mechanism for that depends on your processes. The structure of the unzipped nupkg is: - -``` -│ shimexample.nuspec -│ [Content_Types].xml -│ -├───package -│ └───services -│ └───metadata -│ └───core-properties -│ 9c20d06e1d8b4a4ba3e126f30013ef32.psmdcp -│ -├───tools -│ └───netcoreapp2.1 -│ └───any -│ │ DotnetToolSettings.xml -│ │ shimexample.deps.json -│ │ shimexample.dll -│ │ shimexample.pdb -│ │ shimexample.runtimeconfig.json -│ │ -│ └───shims -│ ├───osx-x64 -│ │ shimexample -│ │ -│ ├───win-x64 -│ │ shimexample.exe -│ │ -│ └───win-x86 -│ shimexample.exe -│ -└───_rels - .rels -``` diff --git a/Documentation/general/tool-nuget-package-format.md b/Documentation/general/tool-nuget-package-format.md deleted file mode 100644 index 0fd0f39b6..000000000 --- a/Documentation/general/tool-nuget-package-format.md +++ /dev/null @@ -1,29 +0,0 @@ -Tool NuGet package format -------------------------------------------- - -The most straightforward way to create a .NET tool package is to run `dotnet pack` with `PackAsTool` property set in the project file. However, if your build process is highly customized, `dotnet publish` may not create the right package for you. In this case, you can create a NuGet package for your tool using a *nuspec* file and explicitly placing assets into the NuGet package following these rules. - -- The NuGet package has only _/tools_ folder under the root and does **not** contain any other folders; do not include folders like _/lib_, _/content_, etc. -- Under _/tools_ folder, the subfolders must be structured with pattern _target framework short version/RID_. For example, tool assets targeting .NET core framework V2.1 that are portable across platforms should be in the folder _tools/netcoreapp2.1/any_. - -Let's call assets under every _tools/target framework short version/RID_ combination "per TFM-RID assets" : -- There is a DotnetToolSettings.xml for every "per TFM-RID assets". -- The package type is DotnetTool. -- Each set of TFM-RID assets should have all the dependencies the tool requires to run. The TFM-RID assets should work correctly after being copied via `xcopy` to another machine, assuming that machine has the correct runtime version and RID environment. -- For portable app, there must be runtimeconfig.json for every "per TFM-RID assets". - -# Remark: -- Currently, only portable apps are supported so the RID must be _any_. -- Only one tool per tool package. - -DotnetToolSettings.xml: -Example: -```xml - - - - - - -``` -Currently only configurable part is command name: _sayhello_ and entry point: _console.dll_. Command Name is what the user will type in their shell to invoke the command. Entry point is the relative path to the entry dll with main. diff --git a/TestAssets/TestPackages/dotnet-dependency-tool-invoker/dotnet-dependency-tool-invoker.csproj b/TestAssets/TestPackages/dotnet-dependency-tool-invoker/dotnet-dependency-tool-invoker.csproj index 0da9b9949..88edf2f41 100644 --- a/TestAssets/TestPackages/dotnet-dependency-tool-invoker/dotnet-dependency-tool-invoker.csproj +++ b/TestAssets/TestPackages/dotnet-dependency-tool-invoker/dotnet-dependency-tool-invoker.csproj @@ -1,8 +1,5 @@  - - - + diff --git a/TestAssets/TestProjects/TestAppsWithSlnAndMultitargetedProjects/MultitargetedCS/MultitargetedCS.csproj b/TestAssets/TestProjects/TestAppsWithSlnAndMultitargetedProjects/MultitargetedCS/MultitargetedCS.csproj deleted file mode 100644 index 988358c8a..000000000 --- a/TestAssets/TestProjects/TestAppsWithSlnAndMultitargetedProjects/MultitargetedCS/MultitargetedCS.csproj +++ /dev/null @@ -1,8 +0,0 @@ - - - - Exe - netcoreapp2.2 - - - diff --git a/TestAssets/TestProjects/TestAppsWithSlnAndMultitargetedProjects/MultitargetedCS/Program.cs b/TestAssets/TestProjects/TestAppsWithSlnAndMultitargetedProjects/MultitargetedCS/Program.cs deleted file mode 100644 index 83d14f592..000000000 --- a/TestAssets/TestProjects/TestAppsWithSlnAndMultitargetedProjects/MultitargetedCS/Program.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace MultitargetedCS -{ - class Program - { - static void Main(string[] args) - { - Console.WriteLine("Hello World!"); - } - } -} diff --git a/TestAssets/TestProjects/TestAppsWithSlnAndMultitargetedProjects/MultitargetedFS/MultitargetedFS.fsproj b/TestAssets/TestProjects/TestAppsWithSlnAndMultitargetedProjects/MultitargetedFS/MultitargetedFS.fsproj deleted file mode 100644 index 2d0082582..000000000 --- a/TestAssets/TestProjects/TestAppsWithSlnAndMultitargetedProjects/MultitargetedFS/MultitargetedFS.fsproj +++ /dev/null @@ -1,12 +0,0 @@ - - - - Exe - netcoreapp2.2 - - - - - - - diff --git a/TestAssets/TestProjects/TestAppsWithSlnAndMultitargetedProjects/MultitargetedFS/Program.fs b/TestAssets/TestProjects/TestAppsWithSlnAndMultitargetedProjects/MultitargetedFS/Program.fs deleted file mode 100644 index a7458f522..000000000 --- a/TestAssets/TestProjects/TestAppsWithSlnAndMultitargetedProjects/MultitargetedFS/Program.fs +++ /dev/null @@ -1,8 +0,0 @@ -// Learn more about F# at http://fsharp.org - -open System - -[] -let main argv = - printfn "Hello World from F#!" - 0 // return an integer exit code diff --git a/TestAssets/TestProjects/TestAppsWithSlnAndMultitargetedProjects/MultitargetedVB/MultitargetedVB.vbproj b/TestAssets/TestProjects/TestAppsWithSlnAndMultitargetedProjects/MultitargetedVB/MultitargetedVB.vbproj deleted file mode 100644 index da41d91f8..000000000 --- a/TestAssets/TestProjects/TestAppsWithSlnAndMultitargetedProjects/MultitargetedVB/MultitargetedVB.vbproj +++ /dev/null @@ -1,9 +0,0 @@ - - - - Exe - MultitargetedVB - netcoreapp2.2 - - - diff --git a/TestAssets/TestProjects/TestAppsWithSlnAndMultitargetedProjects/MultitargetedVB/Program.vb b/TestAssets/TestProjects/TestAppsWithSlnAndMultitargetedProjects/MultitargetedVB/Program.vb deleted file mode 100644 index 46283ca23..000000000 --- a/TestAssets/TestProjects/TestAppsWithSlnAndMultitargetedProjects/MultitargetedVB/Program.vb +++ /dev/null @@ -1,7 +0,0 @@ -Imports System - -Module Program - Sub Main(args As String()) - Console.WriteLine("Hello World!") - End Sub -End Module diff --git a/TestAssets/TestProjects/TestAppsWithSlnAndMultitargetedProjects/TestAppsWithSlnAndMultitargetedProjects.sln b/TestAssets/TestProjects/TestAppsWithSlnAndMultitargetedProjects/TestAppsWithSlnAndMultitargetedProjects.sln deleted file mode 100644 index 2f92ebd9b..000000000 --- a/TestAssets/TestProjects/TestAppsWithSlnAndMultitargetedProjects/TestAppsWithSlnAndMultitargetedProjects.sln +++ /dev/null @@ -1,18 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26124.0 -MinimumVisualStudioVersion = 15.0.26124.0 -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/build/BundledTemplates.props b/build/BundledTemplates.props index e3e280bbf..f8886e06a 100644 --- a/build/BundledTemplates.props +++ b/build/BundledTemplates.props @@ -1,8 +1,8 @@ - - + + diff --git a/build/DependencyVersions.props b/build/DependencyVersions.props index 4d014990b..e964a92c0 100644 --- a/build/DependencyVersions.props +++ b/build/DependencyVersions.props @@ -18,7 +18,7 @@ 3.0.0-preview1-26909-04 - + 3.0.0-preview1-26816-04 @@ -28,7 +28,6 @@ 1.0.2-beta4-20180803-1918431 $(MicrosoftDotNetCommonItemTemplatesPackageVersion) 1.0.2-beta4-20180821-1966911 - 0.2.0 1.5.1 diff --git a/build/run-build.ps1 b/build/run-build.ps1 new file mode 100644 index 000000000..e69de29bb diff --git a/run-build.ps1 b/run-build.ps1 index 8e54ae652..e0db7acb9 100644 --- a/run-build.ps1 +++ b/run-build.ps1 @@ -113,6 +113,6 @@ if ($NoBuild) else { dotnet msbuild build.proj /bl:msbuild.generatepropsfile.binlog /p:Architecture=$Architecture /p:GeneratePropsFile=true /t:WriteDynamicPropsToStaticPropsFiles $ExtraParametersNoTargets - dotnet msbuild build.proj /bl:msbuild.generatepropsfile.binlog /m /v:normal /fl /flp:v=diag /bl /p:Architecture=$Architecture $ExtraParameters + dotnet msbuild build.proj /bl:msbuild.mainbuild.binlog /m /v:normal /fl /flp:v=diag /bl /p:Architecture=$Architecture $ExtraParameters if($LASTEXITCODE -ne 0) { throw "Failed to build" } } diff --git a/src/Microsoft.DotNet.MSBuildSdkResolver/Interop.cs b/src/Microsoft.DotNet.MSBuildSdkResolver/Interop.cs deleted file mode 100644 index cda6dd3d0..000000000 --- a/src/Microsoft.DotNet.MSBuildSdkResolver/Interop.cs +++ /dev/null @@ -1,135 +0,0 @@ -// 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 System; -using System.IO; -using System.Runtime.InteropServices; -using System.Text; - -namespace Microsoft.DotNet.MSBuildSdkResolver -{ - internal static partial class Interop - { - internal static readonly bool RunningOnWindows = -#if NET46 - // Not using RuntimeInformation on NET46 to avoid non-in-box framework API, - // which create deployment problems for the resolver. - Path.DirectorySeparatorChar == '\\'; -#else - RuntimeInformation.IsOSPlatform(OSPlatform.Windows); -#endif - - static Interop() - { - if (RunningOnWindows) - { - PreloadWindowsLibrary("hostfxr.dll"); - } - } - - // MSBuild SDK resolvers are required to be AnyCPU, but we have a native dependency and .NETFramework does not - // have a built-in facility for dynamically loading user native dlls for the appropriate platform. We therefore - // preload the version with the correct architecture (from a corresponding sub-folder relative to us) on static - // construction so that subsequent P/Invokes can find it. - private static void PreloadWindowsLibrary(string dllFileName) - { - string basePath = Path.GetDirectoryName(typeof(Interop).Assembly.Location); - string architecture = IntPtr.Size == 8 ? "x64" : "x86"; - string dllPath = Path.Combine(basePath, architecture, dllFileName); - - // return value is intentially ignored as we let the subsequent P/Invokes fail naturally. - LoadLibraryExW(dllPath, IntPtr.Zero, LOAD_WITH_ALTERED_SEARCH_PATH); - } - - // lpFileName passed to LoadLibraryEx must be a full path. - private const int LOAD_WITH_ALTERED_SEARCH_PATH = 0x8; - - [DllImport("kernel32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] - private static extern IntPtr LoadLibraryExW(string lpFileName, IntPtr hFile, int dwFlags); - - - [Flags] - internal enum hostfxr_resolve_sdk2_flags_t : int - { - disallow_prerelease = 0x1, - } - - internal enum hostfxr_resolve_sdk2_result_key_t : int - { - resolved_sdk_dir = 0, - global_json_path = 1, - } - - internal static class Windows - { - private const CharSet UTF16 = CharSet.Unicode; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = UTF16)] - internal delegate void hostfxr_resolve_sdk2_result_fn( - hostfxr_resolve_sdk2_result_key_t key, - string value); - - [DllImport("hostfxr", CharSet = UTF16, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] - internal static extern int hostfxr_resolve_sdk2( - string exe_dir, - string working_dir, - hostfxr_resolve_sdk2_flags_t flags, - hostfxr_resolve_sdk2_result_fn result); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = UTF16)] - internal delegate void hostfxr_get_available_sdks_result_fn( - int sdk_count, - [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] - string[] sdk_dirs); - - [DllImport("hostfxr", CharSet = UTF16, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] - internal static extern int hostfxr_get_available_sdks( - string exe_dir, - hostfxr_get_available_sdks_result_fn result); - } - - internal static class Unix - { - // Ansi marhsaling on Unix is actually UTF8 - private const CharSet UTF8 = CharSet.Ansi; - private static string PtrToStringUTF8(IntPtr ptr) => Marshal.PtrToStringAnsi(ptr); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = UTF8)] - internal delegate void hostfxr_resolve_sdk2_result_fn( - hostfxr_resolve_sdk2_result_key_t key, - string value); - - [DllImport("hostfxr", CharSet = UTF8, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] - internal static extern int hostfxr_resolve_sdk2( - string exe_dir, - string working_dir, - hostfxr_resolve_sdk2_flags_t flags, - hostfxr_resolve_sdk2_result_fn result); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = UTF8)] - internal delegate void hostfxr_get_available_sdks_result_fn( - int sdk_count, - [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] - string[] sdk_dirs); - - [DllImport("hostfxr", CharSet = UTF8, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] - internal static extern int hostfxr_get_available_sdks( - string exe_dir, - hostfxr_get_available_sdks_result_fn result); - - [DllImport("libc", CharSet = UTF8, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] - private static extern IntPtr realpath(string path, IntPtr buffer); - - [DllImport("libc", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] - private static extern void free(IntPtr ptr); - - internal static string realpath(string path) - { - var ptr = realpath(path, IntPtr.Zero); - var result = PtrToStringUTF8(ptr); - free(ptr); - return result; - } - } - } -} diff --git a/src/Microsoft.DotNet.MSBuildSdkResolver/NETCoreSdkResolver.cs b/src/Microsoft.DotNet.MSBuildSdkResolver/NETCoreSdkResolver.cs deleted file mode 100644 index e00c618d9..000000000 --- a/src/Microsoft.DotNet.MSBuildSdkResolver/NETCoreSdkResolver.cs +++ /dev/null @@ -1,76 +0,0 @@ -// 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 System; -using System.Diagnostics; - -namespace Microsoft.DotNet.MSBuildSdkResolver -{ - internal static class NETCoreSdkResolver - { - public sealed class Result - { - /// - /// Path to .NET Core SDK selected by hostfxr (e.g. C:\Program Files\dotnet\sdk\2.1.300). - /// - public string ResolvedSdkDirectory; - - /// - /// Path to global.json file that impacted resolution. - /// - public string GlobalJsonPath; - - public void Initialize(Interop.hostfxr_resolve_sdk2_result_key_t key, string value) - { - switch (key) - { - case Interop.hostfxr_resolve_sdk2_result_key_t.resolved_sdk_dir: - ResolvedSdkDirectory = value; - break; - case Interop.hostfxr_resolve_sdk2_result_key_t.global_json_path: - GlobalJsonPath = value; - break; - } - } - } - - public static Result ResolveSdk( - string dotnetExeDirectory, - string globalJsonStartDirectory, - bool disallowPrerelease = false) - { - var result = new Result(); - var flags = disallowPrerelease ? Interop.hostfxr_resolve_sdk2_flags_t.disallow_prerelease : 0; - - int errorCode = Interop.RunningOnWindows - ? Interop.Windows.hostfxr_resolve_sdk2(dotnetExeDirectory, globalJsonStartDirectory, flags, result.Initialize) - : Interop.Unix.hostfxr_resolve_sdk2(dotnetExeDirectory, globalJsonStartDirectory, flags, result.Initialize); - - Debug.Assert((errorCode == 0) == (result.ResolvedSdkDirectory != null)); - return result; - } - - private sealed class SdkList - { - public string[] Entries; - - public void Initialize(int count, string[] entries) - { - entries = entries ?? Array.Empty(); - Debug.Assert(count == entries.Length); - Entries = entries; - } - } - - public static string[] GetAvailableSdks(string dotnetExeDirectory) - { - var list = new SdkList(); - - int errorCode = Interop.RunningOnWindows - ? Interop.Windows.hostfxr_get_available_sdks(dotnetExeDirectory, list.Initialize) - : Interop.Unix.hostfxr_get_available_sdks(dotnetExeDirectory, list.Initialize); - - return list.Entries; - } - } -} diff --git a/src/Microsoft.DotNet.MSBuildSdkResolver/VSSettings.cs b/src/Microsoft.DotNet.MSBuildSdkResolver/VSSettings.cs deleted file mode 100644 index 46dfda2e6..000000000 --- a/src/Microsoft.DotNet.MSBuildSdkResolver/VSSettings.cs +++ /dev/null @@ -1,155 +0,0 @@ -// 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 System; -using System.Diagnostics; -using System.IO; -using System.Runtime.InteropServices; - -#if NET46 -using Microsoft.VisualStudio.Setup.Configuration; -#endif - -namespace Microsoft.DotNet.MSBuildSdkResolver -{ - internal sealed class VSSettings - { - private readonly object _lock = new object(); - private readonly string _settingsFilePath; - private readonly bool _disallowPrereleaseByDefault; - private FileInfo _settingsFile; - private bool _disallowPrerelease; - - // In the product, this singleton is used. It must be safe to use in parallel on multiple threads. - // In tests, mock instances can be created with the test constructor below. - public static readonly VSSettings Ambient = new VSSettings(); - - private VSSettings() - { -#if NET46 - if (!Interop.RunningOnWindows) - { - return; - } - - string instanceId; - string installationVersion; - bool isPrerelease; - - try - { - var configuration = new SetupConfiguration(); - var instance = configuration.GetInstanceForCurrentProcess(); - - instanceId = instance.GetInstanceId(); - installationVersion = instance.GetInstallationVersion(); - isPrerelease = ((ISetupInstanceCatalog)instance).IsPrerelease(); - } - catch (COMException) - { - return; - } - - var version = Version.Parse(installationVersion); - - _settingsFilePath = Path.Combine( - Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), - "Microsoft", - "VisualStudio", - version.Major + ".0_" + instanceId, - "sdk.txt"); - - _disallowPrereleaseByDefault = !isPrerelease; - _disallowPrerelease = _disallowPrereleaseByDefault; -#endif - } - - // Test constructor - public VSSettings(string settingsFilePath, bool disallowPrereleaseByDefault) - { - _settingsFilePath = settingsFilePath; - _disallowPrereleaseByDefault = disallowPrereleaseByDefault; - _disallowPrerelease = _disallowPrereleaseByDefault; - } - - public bool DisallowPrerelease() - { - if (_settingsFilePath != null) - { - Refresh(); - } - - return _disallowPrerelease; - } - - private void Refresh() - { - Debug.Assert(_settingsFilePath != null); - - var file = new FileInfo(_settingsFilePath); - - // NB: All calls to Exists and LastWriteTimeUtc below will not hit the disk - // They will return data obtained during Refresh() here. - file.Refresh(); - - lock (_lock) - { - // File does not exist -> use default. - if (!file.Exists) - { - _disallowPrerelease = _disallowPrereleaseByDefault; - _settingsFile = file; - return; - } - - // File has not changed -> reuse prior read. - if (_settingsFile?.Exists == true && file.LastWriteTimeUtc <= _settingsFile.LastWriteTimeUtc) - { - return; - } - - // File has changed -> read from disk - // If we encounter an I/O exception, assume writer is in the process of updating file, - // ignore the exception, and use stale settings until the next resolution. - try - { - ReadFromDisk(); - _settingsFile = file; - return; - } - catch (IOException) { } - catch (UnauthorizedAccessException) { } - } - } - - private void ReadFromDisk() - { - using (var reader = new StreamReader(_settingsFilePath)) - { - string line; - while ((line = reader.ReadLine()) != null) - { - int indexOfEquals = line.IndexOf('='); - if (indexOfEquals < 0 || indexOfEquals == (line.Length - 1)) - { - continue; - } - - string key = line.Substring(0, indexOfEquals).Trim(); - string value = line.Substring(indexOfEquals + 1).Trim(); - - if (key.Equals("UsePreviews", StringComparison.OrdinalIgnoreCase) - && bool.TryParse(value, out bool usePreviews)) - { - _disallowPrerelease = !usePreviews; - return; - } - } - } - - // File does not have UsePreviews entry -> use default - _disallowPrerelease = _disallowPrereleaseByDefault; - } - } -} - diff --git a/src/dotnet/ToolPackage/PackageLocation.cs b/src/dotnet/ToolPackage/PackageLocation.cs deleted file mode 100644 index c0838d1b5..000000000 --- a/src/dotnet/ToolPackage/PackageLocation.cs +++ /dev/null @@ -1,23 +0,0 @@ - -using System; -using Microsoft.Extensions.EnvironmentAbstractions; - -namespace Microsoft.DotNet.ToolPackage -{ - internal class PackageLocation - { - public PackageLocation( - FilePath? nugetConfig = null, - DirectoryPath? rootConfigDirectory = null, - string[] additionalFeeds = null) - { - NugetConfig = nugetConfig; - RootConfigDirectory = rootConfigDirectory; - AdditionalFeeds = additionalFeeds ?? Array.Empty(); - } - - public FilePath? NugetConfig { get; } - public DirectoryPath? RootConfigDirectory { get; } - public string[] AdditionalFeeds { get; } - } -} diff --git a/src/dotnet/commands/dotnet-tool/ToolCommandRestorePassThroughOptions.cs b/src/dotnet/commands/dotnet-tool/ToolCommandRestorePassThroughOptions.cs deleted file mode 100644 index 511f8b867..000000000 --- a/src/dotnet/commands/dotnet-tool/ToolCommandRestorePassThroughOptions.cs +++ /dev/null @@ -1,36 +0,0 @@ -// 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.Cli.CommandLine; -using LocalizableStrings = Microsoft.DotNet.Tools.Restore.LocalizableStrings; - - -namespace Microsoft.DotNet.Cli -{ - internal static class ToolCommandRestorePassThroughOptions - { - public static Option DisableParallelOption() - { - return Create.Option( - "--disable-parallel", - LocalizableStrings.CmdDisableParallelOptionDescription, - Accept.NoArguments().ForwardAs("--disable-parallel")); - } - - public static Option NoCacheOption() - { - return Create.Option( - "--no-cache", - LocalizableStrings.CmdNoCacheOptionDescription, - Accept.NoArguments().ForwardAs("--no-cache")); - } - - public static Option IgnoreFailedSourcesOption() - { - return Create.Option( - "--ignore-failed-sources", - LocalizableStrings.CmdIgnoreFailedSourcesOptionDescription, - Accept.NoArguments().ForwardAs("--ignore-failed-sources")); - } - } -}