Skip to content

Commit 4ea6193

Browse files
Add another Gulp task to fetch all platform packages
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.
1 parent 02b3b37 commit 4ea6193

File tree

2 files changed

+49
-22
lines changed

2 files changed

+49
-22
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ VSIXs can be created using the gulp command `gulp vsix:release:package`. This w
4949

5050
To update the version of the roslyn server used by the extension do the following:
5151
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.
52-
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.
52+
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.
5353
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.
54-
4. Build and test the change (make sure to run `gulp installDependencies` to get the new version!). If everything looks good, submit a PR.
55-
* 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.
54+
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.
55+
5. Build and test the change. If everything looks good, submit a PR.

tasks/offlinePackagingTasks.ts

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,48 @@ gulp.task('installDependencies', async () => {
7373
}
7474
});
7575

76+
gulp.task(
77+
'updateRoslynVersion',
78+
// Run the fetch of all packages, and then also installDependencies after
79+
gulp.series(async () => {
80+
const packageJSON = getPackageJSON();
81+
82+
// Fetch the neutral package that we don't otherwise have in our platform list
83+
await acquireRoslyn(packageJSON, undefined, true);
84+
85+
// And now fetch each platform specific
86+
for (const p of platformSpecificPackages) {
87+
await acquireRoslyn(packageJSON, p.platformInfo, true);
88+
}
89+
}, 'installDependencies')
90+
);
91+
7692
// Install Tasks
7793
async function installRoslyn(packageJSON: any, platformInfo?: PlatformInformation) {
94+
const { packagePath, serverPlatform } = await acquireRoslyn(packageJSON, platformInfo, false);
95+
96+
// Get the directory containing the server executable for the current platform.
97+
const serverExecutableDirectory = path.join(packagePath, 'content', 'LanguageServer', serverPlatform);
98+
if (!fs.existsSync(serverExecutableDirectory)) {
99+
throw new Error(`Failed to find server executable directory at ${serverExecutableDirectory}`);
100+
}
101+
102+
console.log(`Extracting Roslyn executables from ${serverExecutableDirectory}`);
103+
104+
// Copy the files to the language server directory.
105+
fs.mkdirSync(languageServerDirectory);
106+
fsextra.copySync(serverExecutableDirectory, languageServerDirectory);
107+
const languageServerDll = path.join(languageServerDirectory, 'Microsoft.CodeAnalysis.LanguageServer.dll');
108+
if (!fs.existsSync(languageServerDll)) {
109+
throw new Error(`Failed to copy server executable`);
110+
}
111+
}
112+
113+
async function acquireRoslyn(
114+
packageJSON: any,
115+
platformInfo: PlatformInformation | undefined,
116+
interactive: boolean
117+
): Promise<{ packagePath: string; serverPlatform: string }> {
78118
const roslynVersion = packageJSON.defaults.roslyn;
79119

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

92132
const packagePath = await acquireNugetPackage(
93133
`Microsoft.CodeAnalysis.LanguageServer.${serverPlatform}`,
94-
roslynVersion
134+
roslynVersion,
135+
interactive
95136
);
96-
97-
// Get the directory containing the server executable for the current platform.
98-
const serverExecutableDirectory = path.join(packagePath, 'content', 'LanguageServer', serverPlatform);
99-
if (!fs.existsSync(serverExecutableDirectory)) {
100-
throw new Error(`Failed to find server executable directory at ${serverExecutableDirectory}`);
101-
}
102-
103-
console.log(`Extracting Roslyn executables from ${serverExecutableDirectory}`);
104-
105-
// Copy the files to the language server directory.
106-
fs.mkdirSync(languageServerDirectory);
107-
fsextra.copySync(serverExecutableDirectory, languageServerDirectory);
108-
const languageServerDll = path.join(languageServerDirectory, 'Microsoft.CodeAnalysis.LanguageServer.dll');
109-
if (!fs.existsSync(languageServerDll)) {
110-
throw new Error(`Failed to copy server executable`);
111-
}
137+
return { packagePath, serverPlatform };
112138
}
113139

114140
async function installRazor(packageJSON: any, platformInfo: PlatformInformation) {
@@ -142,7 +168,7 @@ async function installPackageJsonDependency(
142168
}
143169
}
144170

145-
async function acquireNugetPackage(packageName: string, packageVersion: string): Promise<string> {
171+
async function acquireNugetPackage(packageName: string, packageVersion: string, interactive: boolean): Promise<string> {
146172
packageName = packageName.toLocaleLowerCase();
147173
const packageOutputPath = path.join(nugetTempPath, packageName, packageVersion);
148174
if (fs.existsSync(packageOutputPath)) {
@@ -157,7 +183,8 @@ async function acquireNugetPackage(packageName: string, packageVersion: string):
157183
`/p:PackageName=${packageName}`,
158184
`/p:PackageVersion=${packageVersion}`,
159185
];
160-
if (argv.interactive) {
186+
187+
if (interactive) {
161188
dotnetArgs.push('--interactive');
162189
}
163190

0 commit comments

Comments
 (0)