diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc
index ad9f31b61e..bac06c9fd2 100644
--- a/CHANGELOG.adoc
+++ b/CHANGELOG.adoc
@@ -52,6 +52,7 @@ The full list of changes for this release can be found in https://github.com/dev
Release with new features and bugfixes:
+* https://github.com/devonfw/IDEasy/issues/694[#694]: Improved dotnet installation
* https://github.com/devonfw/IDEasy/issues/2102[#2102]: IDE_ROOT environment variable is not available to ideasy.exe during MSI installation
* https://github.com/devonfw/IDEasy/issues/1594[#1594]: Add release commandlet
* https://github.com/devonfw/IDEasy/issues/1982[#1982]: Modified fallback link creation on Windows
diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/dotnet/DotNet.java b/cli/src/main/java/com/devonfw/tools/ide/tool/dotnet/DotNet.java
index b897d77f15..84e99811e2 100644
--- a/cli/src/main/java/com/devonfw/tools/ide/tool/dotnet/DotNet.java
+++ b/cli/src/main/java/com/devonfw/tools/ide/tool/dotnet/DotNet.java
@@ -4,7 +4,9 @@
import com.devonfw.tools.ide.common.Tag;
import com.devonfw.tools.ide.context.IdeContext;
+import com.devonfw.tools.ide.process.EnvironmentContext;
import com.devonfw.tools.ide.tool.LocalToolCommandlet;
+import com.devonfw.tools.ide.tool.ToolInstallation;
/**
* {@link LocalToolCommandlet} for dotnet. The .NET CLI (Command Line Interface)
@@ -27,4 +29,14 @@ public String getToolHelpArguments() {
return "help";
}
+
+ @Override
+ public void setEnvironment(
+ EnvironmentContext environmentContext,
+ ToolInstallation toolInstallation,
+ boolean additionalInstallation) {
+
+ super.setEnvironment(environmentContext, toolInstallation, additionalInstallation);
+ environmentContext.withEnvVar("DOTNET_ROOT", toolInstallation.linkDir().toString());
+ }
}
diff --git a/cli/src/test/java/com/devonfw/tools/ide/tool/dotnet/DotNetTest.java b/cli/src/test/java/com/devonfw/tools/ide/tool/dotnet/DotNetTest.java
index 6c16c9d5dd..e071a56ac7 100644
--- a/cli/src/test/java/com/devonfw/tools/ide/tool/dotnet/DotNetTest.java
+++ b/cli/src/test/java/com/devonfw/tools/ide/tool/dotnet/DotNetTest.java
@@ -1,14 +1,24 @@
package com.devonfw.tools.ide.tool.dotnet;
import java.nio.file.Path;
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import com.devonfw.tools.ide.context.AbstractIdeContextTest;
import com.devonfw.tools.ide.context.IdeTestContext;
+import com.devonfw.tools.ide.environment.EnvironmentVariablesType;
+import com.devonfw.tools.ide.environment.VariableLine;
+import com.devonfw.tools.ide.environment.VariableSource;
import com.devonfw.tools.ide.os.SystemInfo;
import com.devonfw.tools.ide.os.SystemInfoMock;
+import com.devonfw.tools.ide.os.WindowsPathSyntax;
+import com.devonfw.tools.ide.process.EnvironmentVariableCollectorContext;
+import com.devonfw.tools.ide.tool.ToolInstallation;
+import com.devonfw.tools.ide.version.VersionIdentifier;
/**
* Test of {@link DotNet}.
@@ -85,4 +95,31 @@ private static void assignDummyUserHome(IdeTestContext context, String pathStrin
Path dummyUserHomePath = PROJECTS_TARGET_PATH.resolve(PROJECT_DOTNET).resolve(pathString);
context.setUserHome(dummyUserHomePath);
}
+
+ @Test
+ void testSetEnvironment() {
+
+ // arrange
+ Path dotnetPath = this.context.getSoftwarePath().resolve("dotnet");
+ ToolInstallation installation = new ToolInstallation(
+ dotnetPath,
+ dotnetPath,
+ dotnetPath,
+ VersionIdentifier.of("6.0.419"),
+ true);
+
+ Map variables = new HashMap<>();
+ EnvironmentVariableCollectorContext environmentContext =
+ new EnvironmentVariableCollectorContext(
+ variables,
+ new VariableSource(EnvironmentVariablesType.WORKSPACE, null),
+ WindowsPathSyntax.MSYS);
+
+ this.commandlet.setEnvironment(environmentContext, installation, false);
+
+ assertThat(variables.get("DOTNET_HOME").getValue())
+ .isEqualTo(dotnetPath.toString());
+ assertThat(variables.get("DOTNET_ROOT").getValue())
+ .isEqualTo(dotnetPath.toString());
+ }
}