Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ public override int Execute()
throw new GracefulException(string.Format(CliCommandStrings.CannotCombineSkipManifestAndRollback,
WorkloadInstallCommandParser.SkipManifestUpdateOption.Name, InstallingWorkloadCommandParser.FromRollbackFileOption.Name), isUserError: true);
}
else if (_skipManifestUpdate && SpecifiedWorkloadSetVersionOnCommandLine)
else if (_skipManifestUpdate && SpecifiedWorkloadSetVersionOnCommandLine &&
!IsRunningRestore) // When running restore, we first update workloads, then query the projects to figure out what workloads should be installed, then run the install command.
// When we run the install command we set skipManifestUpdate to true as an optimization to avoid trying to update twice
{
throw new GracefulException(string.Format(CliCommandStrings.CannotCombineSkipManifestAndVersion,
WorkloadInstallCommandParser.SkipManifestUpdateOption.Name, InstallingWorkloadCommandParser.VersionOption.Name), isUserError: true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public GivenDotnetWorkloadRestore(ITestOutputHelper log) : base(log)
[Fact]
public void ProjectsThatDoNotSupportWorkloadsAreNotInspected()
{
if(IsRunningInContainer())
if (IsRunningInContainer())
{
// Skipping test in a Helix container environment due to read-only DOTNET_ROOT, which causes workload restore to fail when writing workload metadata.
return;
Expand All @@ -38,7 +38,7 @@ public void ProjectsThatDoNotSupportWorkloadsAreNotInspected()
[Fact]
public void ProjectsThatDoNotSupportWorkloadsAndAreTransitivelyReferencedDoNotBreakTheBuild()
{
if(IsRunningInContainer())
if (IsRunningInContainer())
{
// Skipping test in a Helix container environment due to read-only DOTNET_ROOT, which causes workload restore to fail when writing workload metadata.
return;
Expand All @@ -58,6 +58,31 @@ public void ProjectsThatDoNotSupportWorkloadsAndAreTransitivelyReferencedDoNotBr
.Pass();
}

[Fact]
public void VersionOptionShouldNotConflictWithSkipManifestUpdate()
{
if (IsRunningInContainer())
{
// Skipping test in a Helix container environment due to read-only DOTNET_ROOT, which causes workload restore to fail when writing workload metadata.
return;
}

var projectPath =
_testAssetsManager
.CopyTestAsset(TransitiveReferenceNoWorkloadsAssetName)
.WithSource()
.Path;

var result = new DotnetWorkloadCommand(Log, "restore", "--version", "9.0.100")
.WithWorkingDirectory(projectPath)
.Execute();

// Should not fail with "Cannot use the --skip-manifest-update and --sdk-version options together"
// The command may fail for other reasons (e.g., version not found), but it should not fail with the skip-manifest-update error
result.StdErr.Should().NotContain("Cannot use the");
result.StdErr.Should().NotContain("--skip-manifest-update");
}

private bool IsRunningInContainer()
{
if (!File.Exists("/.dockerenv"))
Expand Down
Loading