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 2, 2023
1 parent 02b3b37 commit 4ea6193
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 22 deletions.
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ VSIXs can be created using the gulp command `gulp vsix:release:package`. This w

To update the version of the roslyn server used by the extension do the following:
1. Find the the Roslyn signed build you want from [here](https://dnceng.visualstudio.com/internal/_build?definitionId=327&_a=summary). Typically the latest successful build of main is fine.
2. In the official build stage, look for the `Publish Assets` step. In there you will see it publishing the `Microsoft.CodeAnalysis.LanguageServer` package with some version, e.g. `4.6.0-3.23158.4`. Take note of that version number.
2. In the official build stage, look for the `Publish Assets` step. In there you will see it publishing the `Microsoft.CodeAnalysis.LanguageServer.neutral` package with some version, e.g. `4.6.0-3.23158.4`. Take note of that version number.
3. In the [package.json](package.json) inside the `defaults` section update the `roslyn` key to point to the version number you found above in step 2.
4. Build and test the change (make sure to run `gulp installDependencies` to get the new version!). If everything looks good, submit a PR.
* Adding new package versions might require authentication, run with the `--interactive` flag to login. You may need to install [azure artifacts nuget credential provider](https://github.com/microsoft/artifacts-credprovider#installation-on-windows) to run interactive authentication.
4. Ensure that version of the package is in the proper feeds by running `gulp updateRoslynVersion`. Note: you may need to install the [Azure Artifacts NuGet Credential Provider](https://github.com/microsoft/artifacts-credprovider#installation-on-windows) to run interactive authentication.
5. Build and test the change. If everything looks good, submit a PR.
65 changes: 46 additions & 19 deletions tasks/offlinePackagingTasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,48 @@ gulp.task('installDependencies', async () => {
}
});

gulp.task(
'updateRoslynVersion',
// Run the fetch of all packages, and then also installDependencies after
gulp.series(async () => {
const packageJSON = getPackageJSON();

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

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

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

// 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 | undefined,
interactive: boolean
): Promise<{ packagePath: string; serverPlatform: string }> {
const roslynVersion = packageJSON.defaults.roslyn;

// Find the matching server RID for the current platform.
Expand All @@ -91,24 +131,10 @@ async function installRoslyn(packageJSON: any, platformInfo?: PlatformInformatio

const packagePath = await acquireNugetPackage(
`Microsoft.CodeAnalysis.LanguageServer.${serverPlatform}`,
roslynVersion
roslynVersion,
interactive
);

// 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 Expand Up @@ -142,7 +168,7 @@ async function installPackageJsonDependency(
}
}

async function acquireNugetPackage(packageName: string, packageVersion: string): Promise<string> {
async function acquireNugetPackage(packageName: string, packageVersion: string, interactive: boolean): Promise<string> {
packageName = packageName.toLocaleLowerCase();
const packageOutputPath = path.join(nugetTempPath, packageName, packageVersion);
if (fs.existsSync(packageOutputPath)) {
Expand All @@ -157,7 +183,8 @@ async function acquireNugetPackage(packageName: string, packageVersion: string):
`/p:PackageName=${packageName}`,
`/p:PackageVersion=${packageVersion}`,
];
if (argv.interactive) {

if (interactive) {
dotnetArgs.push('--interactive');
}

Expand Down

0 comments on commit 4ea6193

Please sign in to comment.