Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

Fix relative path tool path #9330

Merged
merged 3 commits into from
May 25, 2018

Conversation

wli3
Copy link

@wli3 wli3 commented May 22, 2018

fix https://github.com/dotnet/cli/issues/9319

Replace PathUtility with new Path.GetRelativePath corefx api

Pass pull path to such api


It would like to have a next step later that enforces DirectoryPath and FilePath always store full path. The problem I have is Path behaves differently in windows and mac. For example, /home means different thing in windows and unix. So if I store full path currently, a lot of test will fail. But I think it worth to do the proper fix to eliminate the whole class of bugs

@@ -119,6 +119,11 @@ public static string GetRelativePath(DirectoryInfo directory, FileSystemInfo chi
/// </summary>
public static string GetRelativePath(string path1, string path2)
{
if (!Path.IsPathRooted(path1) || !Path.IsPathRooted(path2))

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@wli3 wli3 force-pushed the fix-relative-path-tool-path branch from 18216c0 to a2f0729 Compare May 22, 2018 18:18
var appHostDestinationFilePath = shimPath.Value;
var appBinaryFilePath = PathUtility.GetRelativePath(appHostDestinationFilePath, entryPoint.Value);
var appHostDestinationFilePath = Path.GetFullPath(shimPath.Value);
var appBinaryFilePath = Path.GetRelativePath(Path.GetDirectoryName(appHostDestinationFilePath), Path.GetFullPath(entryPoint.Value));

This comment was marked as spam.

@wli3 wli3 requested review from a team and peterhuene May 22, 2018 18:23
@wli3 wli3 added this to the 2.1.4xx milestone May 22, 2018
@peterhuene
Copy link

peterhuene commented May 22, 2018

Do we have a test to cover the execution of the shim with --tool-path so that we can ensure this regression doesn't happen again?

@wli3
Copy link
Author

wli3 commented May 22, 2018

let me add test

@wli3 wli3 force-pushed the fix-relative-path-tool-path branch from a2f0729 to 9a7ea3b Compare May 22, 2018 23:54
@wli3 wli3 force-pushed the fix-relative-path-tool-path branch from 9a7ea3b to 42e1bee Compare May 22, 2018 23:57
@@ -45,6 +45,27 @@ public void GivenAnExecutablePathItCanGenerateShimFile()
stdOut.Should().Contain("Hello World");
}

// Reproduce https://github.com/dotnet/cli/issues/9319

This comment was marked as spam.

@wli3
Copy link
Author

wli3 commented May 23, 2018

@dotnet-bot test Ubuntu x64 Release Build

@wli3
Copy link
Author

wli3 commented May 24, 2018

🔔 @peterhuene @nguerrera :)

@wli3 wli3 merged commit 983612b into dotnet:release/2.1.4xx May 25, 2018
@wli3 wli3 deleted the fix-relative-path-tool-path branch May 25, 2018 01:15
livarcocc added a commit to livarcocc/cli-1 that referenced this pull request Jun 8, 2018
* master: (31 commits)
  Updating signing project to use new intermediate directory (int).
  Update runtimeconfig.json doc for 2.1 (dotnet#9382)
  Shortening the path to the intermediate folder by renaming it to int.
  fix typo (dotnet#9364)
  Updating asp.net to 2.2.0 as well.
  Updating the build and tests to work with the 2.2.0 runtime.
  Simplified combining dictionaries in Telemetry
  Fixing 'Channel' and 'BranchName': "release/2.1.4xx" to "master" (dotnet#9362)
  Fix extraction of folders (dotnet#9335)
  Update Sha256Hasher.cs
  Fix relative path tool path (dotnet#9330)
  Insert updated SDK from 2.1.4xx branch
  MSBuild 15.8.60
  Fix crash when user home directory cannot be determined.
  Make `CliFolderPathCalculator` a static class.
  Don't add the ReleaseSuffix to the branding on the CLI when DropSuffix is set to true.
  Add retry when Directory.Move (dotnet#9313)
  Override new SdkResult public properties
  Add reference to Microsoft.Build.NuGetSdkResolver
  Disable crossgen for MSBuild inline-task refs
  ...

	README.md
	build/BranchInfo.props
	build/BundledTemplates.props
	build/DependencyVersions.props
	build/Version.props
	src/redist/redist.csproj
	test/EndToEnd/GivenAspNetAppsResolveImplicitVersions.cs
	tools/CrossGen.Dependencies/CrossGen.Dependencies.csproj
wli3 pushed a commit to wli3/cli that referenced this pull request Jun 15, 2018
Pass full path to Path.GetRelativePath
dotnet-maestro-bot pushed a commit to dotnet-maestro-bot/cli that referenced this pull request Aug 7, 2018
…e_master_cli

* 'master' of /Users/livarcocc/Documents/git/cli: (1063 commits)
  Updating signing project to use new intermediate directory (int).
  Update runtimeconfig.json doc for 2.1 (dotnet#9382)
  Shortening the path to the intermediate folder by renaming it to int.
  fix typo (dotnet#9364)
  Updating asp.net to 2.2.0 as well.
  Updating the build and tests to work with the 2.2.0 runtime.
  Simplified combining dictionaries in Telemetry
  Fixing 'Channel' and 'BranchName': "release/2.1.4xx" to "master" (dotnet#9362)
  Fix extraction of folders (dotnet#9335)
  Update Sha256Hasher.cs
  Fix relative path tool path (dotnet#9330)
  Insert updated SDK from 2.1.4xx branch
  MSBuild 15.8.60
  Fix crash when user home directory cannot be determined.
  Make `CliFolderPathCalculator` a static class.
  Don't add the ReleaseSuffix to the branding on the CLI when DropSuffix is set to true.
  Add retry when Directory.Move (dotnet#9313)
  Override new SdkResult public properties
  Add reference to Microsoft.Build.NuGetSdkResolver
  Disable crossgen for MSBuild inline-task refs
  ...
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants