Skip to content

Commit a62d5df

Browse files
authored
Adding an init script (#8401)
2 parents f7e167a + 1e9bfc4 commit a62d5df

File tree

2 files changed

+67
-3
lines changed

2 files changed

+67
-3
lines changed

CONTRIBUTING.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,15 @@ Follow these steps to build, run, and test the repository:
3636

3737
#### Building
3838

39+
If you have the ability to run powershell, you can invoke "init.ps1" from the root of the repo. If not, the following steps will get build going for you as well:
40+
3941
1. Run `npm install -g vsts-npm-auth`, then run `vsts-npm-auth -config .npmrc` - This command will configure your credentials for the next command.
4042
a. If you have already authenticated before, but the token expired, you may need to run `vsts-npm-auth -config .npmrc -f` instead.
4143
2. Run `npm i` - This command installs the project dependencies.
4244
3. Run `npm i -g gulp` - This command installs Gulp globally.
4345
4. Run `gulp installDependencies` - This command downloads the various dependencies as specified by the version in the [package.json](package.json) file.
44-
5. Run `code .` - This command opens the project in Visual Studio Code.
46+
47+
You can now run `code .` - This command opens the project in Visual Studio Code.
4548

4649
#### Running
4750

@@ -168,7 +171,7 @@ To package this extension, we need to create VSIX Packages. The VSIX packages ca
168171

169172
## Updating the `Roslyn` Language Server Version
170173

171-
In order to pull in new packages from upstreams into the msft_consumption feed we use for restoring, you will need to be a member of the 'CSharp VS Code Extension contributors' group in the [Azure Devops instance](https://dev.azure.com/azure-public/vside/_settings/teams).
174+
In order to pull in new packages from upstreams into the msft_consumption feed we use for restoring, you will need to be a member of the 'CSharp VS Code Extension contributors' group in the [Azure Devops instance](https://dev.azure.com/azure-public/vside/_settings/teams).
172175

173176
To update the version of the roslyn server used by the extension do the following:
174177
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.
@@ -195,5 +198,5 @@ The marketplace release is managed by an internal AzDo pipeline. On the pipelin
195198
1. The branch will **always** be main, no matter if release a build from prerelease or release.
196199
2. Uncheck the "test" option.
197200
3. In "Resources", choose "dotnet-vscode-csharp [officialBuildCI]", then check only the build that should be released, and then confirm with "Use selected run". Based on the selected build, it will automatically determine if it is prerelease or release. ![release pipeline image](./docs/release_pipeline.png)
198-
4. The pipeline parameters should then look something like the following image. Hit "Run". ![release pipeline parameters image](./docs/release_pipeline_params.png)
201+
4. The pipeline parameters should then look something like the following image. Hit "Run". ![release pipeline parameters image](./docs/release_pipeline_params.png)
199202
5. After a bit, the pipeline will request approval from an authorized approver before it actually uploads to the marketplace. Hit approve and it will continue.

init.ps1

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env pwsh
2+
3+
Write-Host "`nStarting init..." -ForegroundColor Cyan
4+
5+
# Cross-platform command execution with error checking
6+
function Run-Command($command, $arguments, $errorMsg) {
7+
Write-Host "Running: $command $($arguments -join ' ')" -ForegroundColor Yellow
8+
9+
# Check if command exists first
10+
if (-not (Get-Command $command -ErrorAction SilentlyContinue)) {
11+
throw "$command is not available on this system. Please ensure you have the command installed globally and it's available in your PATH."
12+
}
13+
14+
& $command @arguments
15+
16+
if ($LASTEXITCODE -ne 0) {
17+
throw "$errorMsg (Exit code: $LASTEXITCODE)"
18+
}
19+
}
20+
21+
22+
Push-Location $PSScriptRoot
23+
24+
try {
25+
Write-Host "`n[1/5] Installing vsts-npm-auth globally..." -ForegroundColor Cyan
26+
Run-Command "npm" @("install", "-g", "vsts-npm-auth") "Failed to install vsts-npm-auth."
27+
28+
Write-Host "`n[2/5] Authenticating with Azure DevOps..." -ForegroundColor Cyan
29+
if (Test-Path ".npmrc") {
30+
try {
31+
Run-Command "vsts-npm-auth" @("-config", ".npmrc") "Initial authentication failed."
32+
}
33+
catch {
34+
Write-Host "Initial authentication failed. Trying with force (-f) flag..." -ForegroundColor DarkYellow
35+
Run-Command "vsts-npm-auth" @("-config", ".npmrc", "-f") "Forced authentication failed."
36+
}
37+
} else {
38+
Write-Host ".npmrc file not found in the current directory." -ForegroundColor Red
39+
throw ".npmrc file not found in the current directory."
40+
}
41+
42+
Write-Host "`n[3/5] Installing project dependencies..." -ForegroundColor Cyan
43+
Run-Command "npm" @("install") "Failed to install project dependencies."
44+
45+
Write-Host "`n[4/5] Installing Gulp globally..." -ForegroundColor Cyan
46+
Run-Command "npm" @("install", "-g", "gulp") "Failed to install Gulp globally."
47+
48+
Write-Host "`n[5/5] Running gulp installDependencies..." -ForegroundColor Cyan
49+
Run-Command "gulp" @("installDependencies") "Failed to run 'gulp installDependencies'."
50+
51+
Write-Host "`n✅ Setup complete." -ForegroundColor Green
52+
}
53+
catch {
54+
Write-Host "`n❌ Setup failed: $($_.Exception.Message)" -ForegroundColor Red
55+
exit 1
56+
}
57+
finally {
58+
Pop-Location
59+
}
60+
61+

0 commit comments

Comments
 (0)