Skip to content

Commit

Permalink
Add another Gulp task to fetch all platform packages
Browse files Browse the repository at this point in the history
We fetch these from an upstream feed that has authenticated feeds
as upstreams of it; this is an easy way to ensure everything is
cached properly for all platforms.
  • Loading branch information
jasonmalinowski committed Sep 1, 2023
1 parent 02b3b37 commit fff9ea1
Showing 1 changed file with 36 additions and 16 deletions.
52 changes: 36 additions & 16 deletions tasks/offlinePackagingTasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,43 @@ gulp.task('installDependencies', async () => {
}
});

gulp.task('fetchAllRoslynPlatformPackages', async () => {
const packageJSON = getPackageJSON();

// Fetch the neutral package that we don't otherwise have in our platform list
await acquireRoslyn(packageJSON, undefined);

// And now fetch each platform specific
for (const p of platformSpecificPackages) {
await acquireRoslyn(packageJSON, p.platformInfo);
}
});

// Install Tasks
async function installRoslyn(packageJSON: any, platformInfo?: PlatformInformation) {
const { packagePath, serverPlatform } = await acquireRoslyn(packageJSON, platformInfo);

// Get the directory containing the server executable for the current platform.
const serverExecutableDirectory = path.join(packagePath, 'content', 'LanguageServer', serverPlatform);
if (!fs.existsSync(serverExecutableDirectory)) {
throw new Error(`Failed to find server executable directory at ${serverExecutableDirectory}`);
}

console.log(`Extracting Roslyn executables from ${serverExecutableDirectory}`);

// Copy the files to the language server directory.
fs.mkdirSync(languageServerDirectory);
fsextra.copySync(serverExecutableDirectory, languageServerDirectory);
const languageServerDll = path.join(languageServerDirectory, 'Microsoft.CodeAnalysis.LanguageServer.dll');
if (!fs.existsSync(languageServerDll)) {
throw new Error(`Failed to copy server executable`);
}
}

async function acquireRoslyn(
packageJSON: any,
platformInfo?: PlatformInformation
): Promise<{ packagePath: string; serverPlatform: string }> {
const roslynVersion = packageJSON.defaults.roslyn;

// Find the matching server RID for the current platform.
Expand All @@ -93,22 +128,7 @@ async function installRoslyn(packageJSON: any, platformInfo?: PlatformInformatio
`Microsoft.CodeAnalysis.LanguageServer.${serverPlatform}`,
roslynVersion
);

// Get the directory containing the server executable for the current platform.
const serverExecutableDirectory = path.join(packagePath, 'content', 'LanguageServer', serverPlatform);
if (!fs.existsSync(serverExecutableDirectory)) {
throw new Error(`Failed to find server executable directory at ${serverExecutableDirectory}`);
}

console.log(`Extracting Roslyn executables from ${serverExecutableDirectory}`);

// Copy the files to the language server directory.
fs.mkdirSync(languageServerDirectory);
fsextra.copySync(serverExecutableDirectory, languageServerDirectory);
const languageServerDll = path.join(languageServerDirectory, 'Microsoft.CodeAnalysis.LanguageServer.dll');
if (!fs.existsSync(languageServerDll)) {
throw new Error(`Failed to copy server executable`);
}
return { packagePath, serverPlatform };
}

async function installRazor(packageJSON: any, platformInfo: PlatformInformation) {
Expand Down

0 comments on commit fff9ea1

Please sign in to comment.