Skip to content

Commit

Permalink
extension: Fix cs dll output dir is relative #7
Browse files Browse the repository at this point in the history
  • Loading branch information
roxk committed Apr 4, 2024
1 parent f1615e8 commit 7935ba5
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,20 +187,20 @@ private async Task OpenAsync(string path, CancellationToken cancellationToken)
}
}

private async Task<string> GetUnpackagedAppNameAsync(Project docProject, string outDir, string exeName)
private async Task<string> GetOutputFullPathAsync(Project docProject, string outDir, string fileName)
{
string previewAppPath = Path.Combine(outDir ?? "", $"{exeName}.exe");
string fullPath = Path.Combine(outDir ?? "", fileName);
// Cs project outdir is relative...Use uri to detect. Relative path somehow throw in ctor
try
{
var uri = new Uri(previewAppPath);
var uri = new Uri(fullPath);
}
catch (Exception)
{
var projectDir = await docProject.GetAttributeAsync("ProjectDir");
previewAppPath = Path.Combine(projectDir, previewAppPath);
fullPath = Path.Combine(projectDir, fullPath);
}
return previewAppPath;
return fullPath;
}

private async Task<(string appPath, string host, string quries)> OpenExeProjectAsync(Project docProject)
Expand All @@ -215,7 +215,7 @@ private async Task<string> GetUnpackagedAppNameAsync(Project docProject, string
else
{
var outDir = await docProject.GetAttributeAsync("OutDir");
previewAppPath = await GetUnpackagedAppNameAsync(docProject, outDir ?? "", targetName ?? "");
previewAppPath = await GetOutputFullPathAsync(docProject, outDir ?? "", $"{targetName}.exe" ?? "");
}
return (previewAppPath, "show", "");
}
Expand Down Expand Up @@ -252,7 +252,7 @@ private async Task<List<string>> GetDllPathsAsync(Project project, CancellationT
}
var targetName = await project.GetAttributeAsync("TargetName");
var outDir = await project.GetAttributeAsync("OutDir");
var dllPath = Path.Combine(outDir, $"{targetName}.dll");
var dllPath = await GetOutputFullPathAsync(project, outDir ?? "", $"{targetName}.dll");
dllPaths.Add(dllPath);
return dllPaths;
}
Expand All @@ -262,7 +262,7 @@ private async Task<List<string>> GetDllPathsAsync(Project project, CancellationT
var source = new CancellationTokenSource();
var projectName = await docProject.GetAttributeAsync("ProjectName");
var outDir = await docProject.GetAttributeAsync("OutDir");
var appPath = await GetUnpackagedAppNameAsync(docProject, $"{outDir}..\\{projectName}_Preview", "WinUI3XamlPreview_DllLoader");
var appPath = await GetOutputFullPathAsync(docProject, $"{outDir}..\\{projectName}_Preview", "WinUI3XamlPreview_DllLoader.exe");
if (_lastOpenedInfo?.AppPath == appPath)
{
return (appPath, "show", "");
Expand Down

0 comments on commit 7935ba5

Please sign in to comment.