Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow ${WinGetConfigRoot} variable expansion (#3237)
Allow settings to use the `$WinGetConfigRoot` variable. This variable means the directory containing the configuration file and is helpful for units that want reference paths that are relative to the location of the configuration file. For example, our test resource can use it like this: ``` properties: configurationVersion: 0.2 resources: - resource: xSimpleTestResource/SimpleFileResource settings: path: '${WinGetConfigRoot}\..\test.txt' content: 'Ella baila sola' ``` To make it PowerShelly, the variable expansion is done ignoring case. Since this is still in preview, the name of the variable can change when `winget configure` release.
- Loading branch information
1 parent
edf4fbe
commit 40d9cd3
Showing
12 changed files
with
186 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -431,6 +431,7 @@ winapifamily | |
windir | ||
windowsdeveloper | ||
winerror | ||
wingetconfigroot | ||
wingetcreate | ||
wingetdev | ||
wingetutil | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...Microsoft.Management.Configuration.Processor/Exceptions/UnitSettingConfigRootException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// ----------------------------------------------------------------------------- | ||
// <copyright file="UnitSettingConfigRootException.cs" company="Microsoft Corporation"> | ||
// Copyright (c) Microsoft Corporation. Licensed under the MIT License. | ||
// </copyright> | ||
// ----------------------------------------------------------------------------- | ||
|
||
namespace Microsoft.Management.Configuration.Processor.Exceptions | ||
{ | ||
using System; | ||
|
||
/// <summary> | ||
/// A setting uses the config root variable and the Path was not set in the ConfigurationSet. | ||
/// </summary> | ||
internal class UnitSettingConfigRootException : Exception | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="UnitSettingConfigRootException"/> class. | ||
/// </summary> | ||
/// <param name="unitName">Unit name.</param> | ||
/// <param name="setting">Setting.</param> | ||
public UnitSettingConfigRootException(string unitName, string setting) | ||
: base($"Unit: {unitName} Setting {setting} requires the ConfigurationSet Path") | ||
{ | ||
this.HResult = ErrorCodes.WinGetConfigUnitSettingConfigRoot; | ||
this.UnitName = unitName; | ||
this.Setting = setting; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the resource name. | ||
/// </summary> | ||
public string UnitName { get; } | ||
|
||
/// <summary> | ||
/// Gets the setting that reference the config root variable. | ||
/// </summary> | ||
public string Setting { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters