Skip to content

Commit 6ecb840

Browse files
Merge pull request #599 from DustinCampbell/fix-relative-path-issue
Fix relative path issue in asset generation
2 parents 70302e9 + ee9298a commit 6ecb840

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

src/assets.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,10 @@ function computeProgramPath(projectData: TargetProjectData) {
140140
let result = '${workspaceRoot}';
141141

142142
if (projectData.projectPath) {
143-
result += vscode.workspace.asRelativePath(projectData.projectPath);
143+
result = path.join(result, path.relative(vscode.workspace.rootPath, projectData.projectPath.fsPath));
144144
}
145145

146-
if (!result.endsWith('/')) {
147-
result += '/';
148-
}
149-
150-
result += `bin/${projectData.configurationName}/${projectData.targetFramework}/${projectData.executableName}`;
146+
result = path.join(result, `bin/${projectData.configurationName}/${projectData.targetFramework}/${projectData.executableName}`);
151147

152148
return result;
153149
}
@@ -233,8 +229,7 @@ function createLaunchJson(projectData: TargetProjectData, isWebProject: boolean)
233229
function createBuildTaskDescription(projectData: TargetProjectData): tasks.TaskDescription {
234230
let buildPath = '';
235231
if (projectData) {
236-
buildPath = '${workspaceRoot}';
237-
buildPath += vscode.workspace.asRelativePath(projectData.projectJsonPath);
232+
buildPath = path.join('${workspaceRoot}', path.relative(vscode.workspace.rootPath, projectData.projectJsonPath.fsPath));
238233
}
239234

240235
return {
@@ -269,8 +264,8 @@ function addTasksJsonIfNecessary(projectData: TargetProjectData, paths: Paths, o
269264
}
270265

271266
interface TargetProjectData {
272-
projectPath: string;
273-
projectJsonPath: string;
267+
projectPath: vscode.Uri;
268+
projectJsonPath: vscode.Uri;
274269
targetFramework: string;
275270
executableName: string;
276271
configurationName: string;
@@ -293,8 +288,8 @@ function findTargetProjectData(projects: protocol.DotNetProject[]): TargetProjec
293288
const config = targetProject.Configurations.find(c => c.Name === configurationName);
294289
if (config) {
295290
return {
296-
projectPath: targetProject.Path,
297-
projectJsonPath: path.join(targetProject.Path, 'project.json'),
291+
projectPath: targetProject.Path ? vscode.Uri.file(targetProject.Path) : undefined,
292+
projectJsonPath: vscode.Uri.file(path.join(targetProject.Path, 'project.json')),
298293
targetFramework: targetProject.Frameworks[0].ShortName,
299294
executableName: path.basename(config.CompilationOutputAssemblyFile),
300295
configurationName
@@ -326,7 +321,7 @@ function hasWebServerDependency(targetProjectData: TargetProjectData): boolean {
326321
return false;
327322
}
328323

329-
let projectJson = fs.readFileSync(targetProjectData.projectJsonPath, 'utf8');
324+
let projectJson = fs.readFileSync(targetProjectData.projectJsonPath.fsPath, 'utf8');
330325
projectJson = projectJson.replace(/^\uFEFF/, '');
331326

332327
let projectJsonObject: any;

0 commit comments

Comments
 (0)