diff --git a/eng/common/SetupNugetSources.ps1 b/eng/common/SetupNugetSources.ps1 index 792b60b49d42..9445c3143258 100644 --- a/eng/common/SetupNugetSources.ps1 +++ b/eng/common/SetupNugetSources.ps1 @@ -157,7 +157,7 @@ if ($dotnet31Source -ne $null) { AddPackageSource -Sources $sources -SourceName "dotnet3.1-internal-transport" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3.1-internal-transport/nuget/v2" -Creds $creds -Username $userName -pwd $Password } -$dotnetVersions = @('5','6','7','8','9') +$dotnetVersions = @('5','6','7','8','9','10') foreach ($dotnetVersion in $dotnetVersions) { $feedPrefix = "dotnet" + $dotnetVersion; diff --git a/eng/common/SetupNugetSources.sh b/eng/common/SetupNugetSources.sh index facb415ca6ff..ddf4efc81a4a 100755 --- a/eng/common/SetupNugetSources.sh +++ b/eng/common/SetupNugetSources.sh @@ -99,7 +99,7 @@ if [ "$?" == "0" ]; then PackageSources+=('dotnet3.1-internal-transport') fi -DotNetVersions=('5' '6' '7' '8' '9') +DotNetVersions=('5' '6' '7' '8' '9' '10') for DotNetVersion in ${DotNetVersions[@]} ; do FeedPrefix="dotnet${DotNetVersion}"; diff --git a/src/Components/Components/src/RouteView.cs b/src/Components/Components/src/RouteView.cs index 46cda45a0fed..36560a2aa342 100644 --- a/src/Components/Components/src/RouteView.cs +++ b/src/Components/Components/src/RouteView.cs @@ -68,6 +68,7 @@ public Task SetParametersAsync(ParameterView parameters) /// Renders the component. /// /// The . + [UnconditionalSuppressMessage("Trimming", "IL2110", Justification = "Layout components are preserved because the LayoutAttribute constructor parameter is correctly annotated.")] [UnconditionalSuppressMessage("Trimming", "IL2111", Justification = "Layout components are preserved because the LayoutAttribute constructor parameter is correctly annotated.")] [UnconditionalSuppressMessage("Trimming", "IL2118", Justification = "Layout components are preserved because the LayoutAttribute constructor parameter is correctly annotated.")] protected virtual void Render(RenderTreeBuilder builder) diff --git a/src/Tools/Shared/SecretsHelpers/MsBuildProjectFinder.cs b/src/Tools/Shared/SecretsHelpers/MsBuildProjectFinder.cs index 6be7bde5299c..e016ed37d06b 100644 --- a/src/Tools/Shared/SecretsHelpers/MsBuildProjectFinder.cs +++ b/src/Tools/Shared/SecretsHelpers/MsBuildProjectFinder.cs @@ -46,7 +46,7 @@ public string FindMsBuildProject(string project) if (!File.Exists(projectPath)) { - throw new FileNotFoundException(SecretsHelpersResources.FormatError_ProjectPath_NotFound(projectPath)); + throw new FileNotFoundException(SecretsHelpersResources.FormatError_File_NotFound(projectPath)); } return projectPath; diff --git a/src/Tools/Shared/SecretsHelpers/ProjectIdResolver.cs b/src/Tools/Shared/SecretsHelpers/ProjectIdResolver.cs index d9c794586ae4..4c3c68c77912 100644 --- a/src/Tools/Shared/SecretsHelpers/ProjectIdResolver.cs +++ b/src/Tools/Shared/SecretsHelpers/ProjectIdResolver.cs @@ -59,9 +59,9 @@ public string Resolve(string project, string configuration) UseShellExecute = false, ArgumentList = { - "msbuild", + "build", projectFile, - "/nologo", + "--no-restore", "/t:_ExtractUserSecretsMetadata", // defined in SecretManager.targets "/p:_UserSecretsMetadataFile=" + outputFile, "/p:Configuration=" + configuration, @@ -72,7 +72,7 @@ public string Resolve(string project, string configuration) }; #if DEBUG - _reporter.Verbose($"Invoking '{psi.FileName} {psi.Arguments}'"); + _reporter.Verbose($"Invoking '{psi.FileName} {string.Join(' ', psi.ArgumentList)}'"); #endif using var process = new Process() diff --git a/src/Tools/Shared/SecretsHelpers/SecretsHelpersResources.resx b/src/Tools/Shared/SecretsHelpers/SecretsHelpersResources.resx index bdc7cd88d5e9..acddbeeb55d2 100644 --- a/src/Tools/Shared/SecretsHelpers/SecretsHelpersResources.resx +++ b/src/Tools/Shared/SecretsHelpers/SecretsHelpersResources.resx @@ -124,7 +124,7 @@ Multiple MSBuild project files found in '{projectPath}'. Specify which to use with the --project option. - Could not find a MSBuild project file in '{projectPath}'. Specify which project to use with the --project option. + Could not find a MSBuild project file in '{projectPath}'. Specify which project to use with the --project option. Use --file option for file-based apps. Could not load the MSBuild project '{project}'. @@ -132,8 +132,8 @@ Could not find the global property 'UserSecretsId' in MSBuild project '{project}'. Ensure this property is set in the project or use the '--id' command line option. - - The project file '{0}' does not exist. + + The file '{0}' does not exist. The MSBuild project '{project}' has already been initialized with a UserSecretsId. @@ -144,4 +144,4 @@ Set UserSecretsId to '{userSecretsId}' for MSBuild project '{project}'. - \ No newline at end of file + diff --git a/src/Tools/dotnet-user-secrets/src/CommandLineOptions.cs b/src/Tools/dotnet-user-secrets/src/CommandLineOptions.cs index af97626c7d89..5587c8e340f5 100644 --- a/src/Tools/dotnet-user-secrets/src/CommandLineOptions.cs +++ b/src/Tools/dotnet-user-secrets/src/CommandLineOptions.cs @@ -16,6 +16,7 @@ public class CommandLineOptions public bool IsHelp { get; private set; } public bool IsVerbose { get; private set; } public string Project { get; private set; } + public string File { get; private set; } public static CommandLineOptions Parse(string[] args, IConsole console) { @@ -36,6 +37,9 @@ public static CommandLineOptions Parse(string[] args, IConsole console) var optionProject = app.Option("-p|--project ", "Path to project. Defaults to searching the current directory.", CommandOptionType.SingleValue, inherited: true); + var optionFile = app.Option("-f|--file ", "Path to file-based app.", + CommandOptionType.SingleValue, inherited: true); + var optionConfig = app.Option("-c|--configuration ", "The project configuration to use. Defaults to 'Debug'.", CommandOptionType.SingleValue, inherited: true); @@ -50,7 +54,7 @@ public static CommandLineOptions Parse(string[] args, IConsole console) app.Command("remove", c => RemoveCommand.Configure(c, options)); app.Command("list", c => ListCommand.Configure(c, options)); app.Command("clear", c => ClearCommand.Configure(c, options)); - app.Command("init", c => InitCommandFactory.Configure(c, options)); + app.Command("init", c => InitCommandFactory.Configure(c, options, optionFile)); // Show help information if no subcommand/option was specified. app.OnExecute(() => app.ShowHelp()); @@ -66,6 +70,12 @@ public static CommandLineOptions Parse(string[] args, IConsole console) options.IsHelp = app.IsShowingInformation; options.IsVerbose = optionVerbose.HasValue(); options.Project = optionProject.Value(); + options.File = optionFile.Value(); + + if (options.File != null && options.Project != null) + { + throw new CommandParsingException(app, Resources.Error_ProjectAndFileOptions); + } return options; } diff --git a/src/Tools/dotnet-user-secrets/src/Internal/InitCommand.cs b/src/Tools/dotnet-user-secrets/src/Internal/InitCommand.cs index d6aa7edd15ab..cf3a9db65ba5 100644 --- a/src/Tools/dotnet-user-secrets/src/Internal/InitCommand.cs +++ b/src/Tools/dotnet-user-secrets/src/Internal/InitCommand.cs @@ -16,13 +16,18 @@ public class InitCommandFactory : ICommand { public CommandLineOptions Options { get; } - internal static void Configure(CommandLineApplication command, CommandLineOptions options) + internal static void Configure(CommandLineApplication command, CommandLineOptions options, CommandOption optionFile) { command.Description = "Set a user secrets ID to enable secret storage"; command.HelpOption(); command.OnExecute(() => { + if (optionFile.HasValue()) + { + throw new CommandParsingException(command, Resources.Error_InitNotSupportedForFileBasedApps); + } + options.Command = new InitCommandFactory(options); }); } diff --git a/src/Tools/dotnet-user-secrets/src/Program.cs b/src/Tools/dotnet-user-secrets/src/Program.cs index f01b7e434678..87f04ce466c3 100644 --- a/src/Tools/dotnet-user-secrets/src/Program.cs +++ b/src/Tools/dotnet-user-secrets/src/Program.cs @@ -106,6 +106,6 @@ internal string ResolveId(CommandLineOptions options, IReporter reporter) } var resolver = new ProjectIdResolver(reporter, _workingDirectory); - return resolver.Resolve(options.Project, options.Configuration); + return resolver.Resolve(options.Project ?? options.File, options.Configuration); } } diff --git a/src/Tools/dotnet-user-secrets/src/Resources.resx b/src/Tools/dotnet-user-secrets/src/Resources.resx index 30d696946c76..de8dae561692 100644 --- a/src/Tools/dotnet-user-secrets/src/Resources.resx +++ b/src/Tools/dotnet-user-secrets/src/Resources.resx @@ -1,4 +1,4 @@ - +