waldo1001 / crs-al-language-extension

Make working with the (Dynamics NAV / 365) AL Language easier and more efficient.
MIT License
34 stars 43 forks source link

Compile DGML not working if .alpackages not in app folder #228

Closed tscottjendev closed 2 years ago

tscottjendev commented 2 years ago

I have a multi-root workspace. For various reasons, I have my .alpackages folder at the same level as all the app folders.

WorkSpaceFolder
 - AppFolder
 - AppFolder2
 - AppFolder3
 - .alpackages

rather than

WorkSpaceFolder
 - AppFolder
   - .alpackages
 - AppFolder2
   - .alpackages
 - AppFolder3
   - .alpackages

When I run the Compile DGML command I get an error because the pathing for the .alpackages folder is incorrect. It is ./alc.exe /project:"c:\Repos\WorkSpaceFolder\AppFolder" /packagecachepath:"c:\Repos\WorkspaceFolder\AppFolder../.alpackages" /generatecrossreferencesckages" /generatecrossreferences rather than ./alc.exe /project:"c:\Repos\WorkSpaceFolder\AppFolder" /packagecachepath:"c:\Repos\WorkspaceFolder\AppFolder\../.alpackages" /generatecrossreferencesckages" /generatecrossreferences

I think the problem is here in ALCExe.ts

    static CompileDGML() {
        let projectpath

        try {
            projectpath = vscode.workspace.getWorkspaceFolder(vscode.window.activeTextEditor.document.uri).uri.fsPath;
        } catch {
            vscode.window.showErrorMessage('No active project document.');
        }

        let workSpaceSettings = Settings.GetConfigSettings(projectpath);
        let packageCachePath = projectpath + workSpaceSettings[Settings.packageCachePath] <<<

        crsOutput.showOutput(`CompileDGML for project "${projectpath}"`, false)

        let alcpath = this.GetALCExeDir();

        CRSTerminal.CompileDGML(alcpath, projectpath, packageCachePath);
    }

This line should try to join paths rather than a straight string concatenation (I think). let packageCachePath = path.Join(projectpath, workSpaceSettings[Settings.packageCachePath]) I don't know if path.Join exists in the library you are using.

Also, wouldn't you need to include /assemblyprobingpaths parameter if there is any .NET references?

waldo1001 commented 2 years ago

Wow - what a rookie mistake. Thanks for the issue, and for pointing to the problem in code!

Sorry that it took so long!