├── .config
└── tsaoptions.json
├── .eslintrc.js
├── .gitattributes
├── .github
└── ISSUE_TEMPLATE
│ ├── bug-report--vs-code-runtime-extension.yml
│ ├── feature-request--vs-code-runtime-extension.yml
│ └── security-fix.yml
├── .gitignore
├── .npmrc
├── .vscode
└── settings.json
├── .vscodeignore
├── 1es-azure-pipeline.yml
├── 1pr-azure-pipeline.yml
├── CODE-OF-CONDUCT.md
├── CODE_OWNERS.txt
├── CONTRIBUTING.md
├── Documentation
├── adding-distros.md
├── commands.md
├── contributing-workflow.md
├── contributing.md
├── copyright.md
├── dev-spec.md
├── example.gif
├── global-installs
│ ├── early-global-code-changes-overview.md
│ ├── global-devkit-adoption-plan.md
│ └── linux-global-install-design.md
├── json-schema
│ └── distro-support-schema.json
├── release.md
├── troubleshooting-runtime.md
└── troubleshooting-sdk.md
├── LICENSE.txt
├── PoliCheckExclusions.xml
├── README.md
├── SUPPORT.md
├── THIRD-PARTY-NOTICES.txt
├── build.cmd
├── build.ps1
├── build.sh
├── dependency-verifier.py
├── global.json
├── images
└── dotnetIcon.png
├── mock-webpack.ps1
├── mock-webpack.sh
├── msbuild
├── Directory.Build.props
├── Directory.Build.rsp
├── Directory.Packages.props
├── signJs
│ └── signJs.proj
└── signVsix
│ └── signVsix.proj
├── nuget.config
├── package-lock.json
├── package.json
├── packages
└── .gitignore
├── pipeline-templates
├── build-test.yaml
├── install-node.yaml
├── lint.yaml
├── package-vsix.yaml
├── prepare-signing.yaml
├── publish.yaml
├── sbom.yaml
└── upstream-verify.yaml
├── sample
├── .npmrc
├── .vscode
│ ├── launch.json
│ ├── settings.json
│ └── tasks.json
├── HelloWorldConsoleApp
│ ├── HelloWorldConsoleApp.deps.json
│ ├── HelloWorldConsoleApp.dll
│ └── HelloWorldConsoleApp.runtimeconfig.json
├── LICENSE.txt
├── package-lock.json
├── package.json
├── src
│ └── extension.ts
├── tsconfig.json
├── tslint.json
└── yarn.lock
├── signing
├── Get-NuGetTool.ps1
├── Get-TempToolsPath.ps1
├── Install-NuGetPackage.ps1
└── Set-EnvVars.ps1
├── test.cmd
├── test.ps1
├── test.sh
├── tsconfig.eslint.json
├── vscode-dotnet-runtime-extension
├── .editorconfig
├── .npmrc
├── .vscode
│ ├── launch.json
│ ├── settings.json
│ └── tasks.json
├── CHANGELOG.md
├── README.md
├── images
│ └── dotnetIcon.png
├── package-lock.json
├── package.json
├── src
│ ├── DotnetCoreAcquisitionId.ts
│ ├── extension.ts
│ └── test
│ │ └── functional
│ │ ├── DotnetCoreAcquisitionExtension.test.ts
│ │ ├── index.ts
│ │ └── runTest.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── vscode-dotnet-runtime-library
├── .npmrc
├── .vscode
│ └── settings.json
├── distro-data
│ └── distro-support.json
├── install scripts
│ ├── determine-linux-distro.sh
│ ├── install-linux-prereqs.sh
│ └── interprocess-communicator.sh
├── package-lock.json
├── package.json
├── src
│ ├── Acquisition
│ │ ├── ASPNetRuntimeInstallationDirectoryProvider.ts
│ │ ├── AcquisitionInvoker.ts
│ │ ├── CacheTimeConstants.ts
│ │ ├── DebianDistroSDKProvider.ts
│ │ ├── DirectoryProviderFactory.ts
│ │ ├── DotnetConditionValidator.ts
│ │ ├── DotnetCoreAcquisitionWorker.ts
│ │ ├── DotnetCoreDependencyInstaller.ts
│ │ ├── DotnetInstall.ts
│ │ ├── DotnetInstallMode.ts
│ │ ├── DotnetPathFinder.ts
│ │ ├── ExistingPathResolver.ts
│ │ ├── GenericDistroSDKProvider.ts
│ │ ├── GlobalInstallerResolver.ts
│ │ ├── IAcquisitionInvoker.ts
│ │ ├── IAcquisitionWorkerContext.ts
│ │ ├── IDistroDotnetSDKProvider.ts
│ │ ├── IDotnetConditionValidator.ts
│ │ ├── IDotnetCoreAcquisitionWorker.ts
│ │ ├── IDotnetInstallationContext.ts
│ │ ├── IDotnetListInfo.ts
│ │ ├── IDotnetPathFinder.ts
│ │ ├── IGlobalInstaller.ts
│ │ ├── IInstallScriptAcquisitionWorker.ts
│ │ ├── IInstallationDirectoryProvider.ts
│ │ ├── IInstallationValidator.ts
│ │ ├── IJsonInstaller.ts
│ │ ├── IRegistryReader.ts
│ │ ├── IVersionResolver.ts
│ │ ├── InstallRecord.ts
│ │ ├── InstallRecordWithPath.ts
│ │ ├── InstallScriptAcquisitionWorker.ts
│ │ ├── InstallTrackerSingleton.ts
│ │ ├── InstallationValidator.ts
│ │ ├── JsonInstaller.ts
│ │ ├── LinuxGlobalInstaller.ts
│ │ ├── LinuxPackageCollection.ts
│ │ ├── LinuxVersionResolver.ts
│ │ ├── RedHatDistroSDKProvider.ts
│ │ ├── RegistryReader.ts
│ │ ├── RuntimeInstallationDirectoryProvider.ts
│ │ ├── SdkInstallationDirectoryProvider.ts
│ │ ├── StringConstants.ts
│ │ ├── VersionResolver.ts
│ │ ├── VersionUtilities.ts
│ │ └── WinMacGlobalInstaller.ts
│ ├── DotnetVersionSpecRequirement.ts
│ ├── EventStream
│ │ ├── EventStream.ts
│ │ ├── EventStreamEvents.ts
│ │ ├── EventStreamRegistration.ts
│ │ ├── EventType.ts
│ │ ├── IEvent.ts
│ │ ├── IEventStreamObserver.ts
│ │ ├── ILoggingObserver.ts
│ │ ├── IModalEventPublisher.ts
│ │ ├── IWindowDisplayWorker.ts
│ │ ├── LoggingObserver.ts
│ │ ├── ModalEventPublisher.ts
│ │ ├── OutputChannelObserver.ts
│ │ ├── StatusBarObserver.ts
│ │ ├── TelemetryObserver.ts
│ │ ├── TelemetryUtilities.ts
│ │ └── WindowDisplayWorker.ts
│ ├── IDotnetAcquireContext.ts
│ ├── IDotnetAcquireResult.ts
│ ├── IDotnetEnsureDependenciesContext.ts
│ ├── IDotnetFindPathContext.ts
│ ├── IDotnetListVersionsContext.ts
│ ├── IDotnetUninstallContext.ts
│ ├── IExtensionContext.ts
│ ├── IExtensionState.ts
│ ├── IVSCodeExtensionContext.ts
│ ├── LocalMemoryCacheSingleton.ts
│ ├── Utils
│ │ ├── CommandExecutor.ts
│ │ ├── CommandExecutorCommand.ts
│ │ ├── CommandExecutorResult.ts
│ │ ├── ContentSantizer.ts
│ │ ├── Debugging.ts
│ │ ├── ErrorHandler.ts
│ │ ├── ExtensionConfigurationWorker.ts
│ │ ├── FileUtilities.ts
│ │ ├── ICommandExecutor.ts
│ │ ├── IExtensionConfigurationWorker.ts
│ │ ├── IFileUtilities.ts
│ │ ├── IIssueContext.ts
│ │ ├── IUtilityContext.ts
│ │ ├── IVSCodeEnvironment.ts
│ │ ├── InstallIdUtilities.ts
│ │ ├── IssueReporter.ts
│ │ ├── LockUsedByThisInstanceSingleton.ts
│ │ ├── NodeIPCMutex.ts
│ │ ├── TypescriptUtilities.ts
│ │ ├── VSCodeEnvironment.ts
│ │ └── WebRequestWorkerSingleton.ts
│ ├── VSCodeExtensionContext.ts
│ ├── index.ts
│ └── test
│ │ ├── mocks
│ │ ├── MockEnvironmentVariableCollection.ts
│ │ ├── MockExtensionConfigurationWorker.ts
│ │ ├── MockObjects.ts
│ │ ├── MockRunTask.ts
│ │ ├── MockWindowDisplayWorker.ts
│ │ ├── mock-channel-6-index.json
│ │ ├── mock-channel-7-index.json
│ │ └── mock-releases.json
│ │ └── unit
│ │ ├── DebianDistroTests.test.ts
│ │ ├── DotnetConditionValidator.test.ts
│ │ ├── DotnetCoreAcquisitionWorker.test.ts
│ │ ├── DotnetPathFinder.test.ts
│ │ ├── ErrorHandler.test.ts
│ │ ├── ExistingPathResolver.test.ts
│ │ ├── GlobalInstallerResolver.test.ts
│ │ ├── InstallTracker.test.ts
│ │ ├── InstallationValidator.test.ts
│ │ ├── IssueReporter.test.ts
│ │ ├── JsonInstaller.test.ts
│ │ ├── LinuxDistroTests.test.ts
│ │ ├── LinuxVersionResolver.test.ts
│ │ ├── LocalMemoryCacheSingleton.test.ts
│ │ ├── LoggingObserver.test.ts
│ │ ├── NodeIPCMutex.test.ts
│ │ ├── RedHatDistroTests.test.ts
│ │ ├── RegistryReader.test.ts
│ │ ├── TestUtility.ts
│ │ ├── VersionResolver.test.ts
│ │ ├── VersionUtilities.test.ts
│ │ ├── WebRequestWorker.test.ts
│ │ └── WinMacGlobalInstaller.test.ts
├── tsconfig.json
└── yarn.lock
├── vscode-dotnet-runtime.code-workspace
├── vscode-dotnet-sdk-extension
├── .npmrc
├── .vscode
│ ├── launch.json
│ ├── settings.json
│ └── tasks.json
├── CHANGELOG.md
├── README.md
├── images
│ └── dotnetIcon.png
├── package-lock.json
├── package.json
├── src
│ ├── DotnetCoreAcquisitionId.ts
│ ├── ExtensionUninstall.ts
│ ├── extension.ts
│ └── test
│ │ ├── functional
│ │ ├── DotnetCoreAcquisitionExtension.test.ts
│ │ ├── index.ts
│ │ └── runTest.ts
│ │ └── mocks
│ │ └── mock-releases.json
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
└── yarn.lock
/.config/tsaoptions.json:
--------------------------------------------------------------------------------
1 | {
2 | "instanceUrl": "https://devdiv.visualstudio.com/",
3 | "template": "TFSDEVDIV",
4 | "projectName": "DEVDIV",
5 | "areaPath": "DevDiv\\NET Tools\\SDK",
6 | "iterationPath": "DevDiv",
7 | "notificationAliases": [ "dotnetdevexcli@microsoft.com" ],
8 | "repositoryName":"vscode-dotnet-runtime",
9 | "codebaseName": "vscode-dotnet-runtime"
10 | }
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.doc diff=astextplain
2 | *.DOC diff=astextplain
3 | *.docx diff=astextplain
4 | *.DOCX diff=astextplain
5 | *.dot diff=astextplain
6 | *.DOT diff=astextplain
7 | *.pdf diff=astextplain
8 | *.PDF diff=astextplain
9 | *.rtf diff=astextplain
10 | *.RTF diff=astextplain
11 |
12 | *.jpg binary
13 | *.png binary
14 | *.gif binary
15 |
16 | *.cs text=auto diff=csharp
17 | *.vb text=auto
18 | *.resx text=auto
19 | *.c text=auto
20 | *.cpp text=auto
21 | *.cxx text=auto
22 | *.h text=auto
23 | *.hxx text=auto
24 | *.py text=auto
25 | *.rb text=auto
26 | *.java text=auto
27 | *.html text=auto
28 | *.htm text=auto
29 | *.css text=auto
30 | *.scss text=auto
31 | *.sass text=auto
32 | *.less text=auto
33 | *.js text=auto
34 | *.lisp text=auto
35 | *.clj text=auto
36 | *.sql text=auto
37 | *.php text=auto
38 | *.lua text=auto
39 | *.m text=auto
40 | *.asm text=auto
41 | *.erl text=auto
42 | *.fs text=auto
43 | *.fsx text=auto
44 | *.hs text=auto
45 |
46 | *.csproj text=auto
47 | *.vbproj text=auto
48 | *.fsproj text=auto
49 | *.dbproj text=auto
50 | *.sln text=auto eol=crlf
51 |
52 | *.sh eol=lf
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug-report--vs-code-runtime-extension.yml:
--------------------------------------------------------------------------------
1 | name: 🐞 Bug Report
2 | description: Create a report a potential bug
3 | labels: ["untriaged"]
4 | body:
5 | - type: markdown
6 | attributes:
7 | value: |
8 | Thanks for taking the time to fill out this bug report!
9 |
10 | 📖 Have you checked existing issues to see whether someone else has already reported your issue?
11 | ❗ Privacy Alert! The contents in our log files may contain personal data. Prior to posting to GitHub, please remove any personal data which should not be publicly viewable. https://privacy.microsoft.com/en-US/privacystatement
12 | - type: textarea
13 | attributes:
14 | label: Describe the bug.
15 | description: |
16 | Please share some details about the issue you are facing with the .NET Install Tool.
17 | Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in.
18 | validations:
19 | required: true
20 | - type: textarea
21 | attributes:
22 | label: Please attach log file(s) here if you have any.
23 | description: |
24 | Our log files are located alongside VS Code logs. If you want to find them manually, navigate here:
25 | Linux: ~/.config/Code/logs
26 | Mac: ~/Library/Application Support/Code/logs/
27 | Windows: c:\Users\USER\AppData\Roaming\Code\logs\
28 |
29 | Then find the folder created at the time you experienced the bug in the logs folder.
30 | From there, go to window1 -> exthost -> ms-dotnettools.vscode-dotnet-runtime. The log file should be located in this folder.
31 |
32 | Note: The window folder may change depending on how many VS Code windows you have open; if our extension is running in the 2nd window, it'd be in a folder called window2.
33 | value: The log file location should be copied to your clipboard if you came from VS Code.
34 | validations:
35 | required: true
36 | - type: textarea
37 | attributes:
38 | label: Reproduction Steps
39 | validations:
40 | required: true
41 | - type: textarea
42 | attributes:
43 | label: Expected Behavior
44 | validations:
45 | required: true
46 | - type: textarea
47 | attributes:
48 | label: Exceptions & Errors (if any)
49 | description: Errors the extension may have encountered have likely been added to your terminal or VS Code windows. Please paste it/them here and describe what happened and the problem you are facing.
50 | validations:
51 | required: false
52 | - type: input
53 | attributes:
54 | label: .NET Install Tool Version
55 | description: e.g. v2.0.0. You can find this by hovering over the extension in VS Code, the version number is to the right of the extension name.
56 | validations:
57 | required: true
58 | - type: dropdown
59 | id: download
60 | attributes:
61 | label: Your operating system? Please provide more detail, such as the version and or distro above.
62 | options:
63 | - Windows
64 | - OSX / Darwin / Mac
65 | - Linux
66 | - Other
67 | - N/A
68 | default: 4
69 | validations:
70 | required: true
71 | - type: input
72 | attributes:
73 | label: VS Code Version
74 | description: e.g. 1.84.2. You can find this in VS Code by going to Help -> About -> and finding the Version.
75 | validations:
76 | required: false
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature-request--vs-code-runtime-extension.yml:
--------------------------------------------------------------------------------
1 | name: ✨ Feature Request
2 | description: Request a new feature for this project
3 | labels: ["feature-request"]
4 | body:
5 | - type: textarea
6 | attributes:
7 | label: Is your feature request related to a problem? Please describe.
8 | placeholder: Example -- I am trying to do [...]. The current feature addresses [...] but does not consider [...].
9 | validations:
10 | required: true
11 | - type: textarea
12 | attributes:
13 | label: A clear and concise description of what you want to happen. Include any alternative solutions you've considered.
14 | placeholder: Example -- I would like to have [...] to change from [...] to [...]. The benefit of this is [...].
15 | validations:
16 | required: true
17 | - type: textarea
18 | attributes:
19 | label: Describe the solution you'd like
20 | validations:
21 | required: true
22 | - type: textarea
23 | attributes:
24 | label: Additional context
25 | description: Add any other context or screenshots about the feature request here.
26 | validations:
27 | required: false
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/security-fix.yml:
--------------------------------------------------------------------------------
1 | name: ⚠️ Security Weakness
2 | description: Report a security vulnerability
3 | labels: ["closeable"]
4 | body:
5 | - type: markdown
6 | attributes:
7 | value: |
8 | Security issues and bugs should be reported privately to the Microsoft Security Response Center (MSRC), either by emailing secure@microsoft.com or via the portal at https://msrc.microsoft.com.
9 |
10 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message.
11 |
12 | Further information, including the MSRC PGP key, can be found in the MSRC Report an Issue FAQ.
13 | - type: textarea
14 | attributes:
15 | label: ⚠️ Please do not open issues for anything you think might have a security implication.
16 | placeholder: Close this window and instead email secure@microsoft.com or disclose the issue via the portal at https://msrc.microsoft.com.
17 | render: cs
18 | validations:
19 | required: true
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | [Oo]bj/
2 | [Bb]in/
3 | TestResults/
4 | .nuget/
5 | .build/
6 | msbuild/signJs/*.log
7 | .testPublish/
8 | *.sln.ide/
9 | _ReSharper.*/
10 | artifacts/
11 | .build/
12 | PublishProfiles/
13 | *.user
14 | *.suo
15 | *.cache
16 | *.docstates
17 | _ReSharper.*
18 | nuget.exe
19 | project.lock.json
20 | *net45.csproj
21 | *net451.csproj
22 | *k10.csproj
23 | *.psess
24 | *.vsp
25 | *.pidb
26 | *.userprefs
27 | *DS_Store
28 | *.ncrunchsolution
29 | *.*sdf
30 | *.ipch
31 | *.js
32 | !.eslintrc.js
33 | *.d.ts
34 | *.js.map
35 | .build/
36 | .vs/
37 | launchSettings.json
38 | BenchmarkDotNet.Artifacts/
39 | msbuild.binlog
40 | msbuild.log
41 | node_modules
42 | .dotnet
43 | out
44 | dist
45 | install.*
46 | .vscode-test/
47 | *.vsix
48 | vscode-dotnet-runtime-library/install scripts/dotnet-install.*
49 | vscode-dotnet-runtime-extension/LICENSE.txt
50 | vscode-dotnet-sdk-extension/LICENSE.txt
51 | .vscode/launch.json
--------------------------------------------------------------------------------
/.npmrc:
--------------------------------------------------------------------------------
1 | registry=https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Ensure that we don't send telemetry when using the sample extension in this workspace
2 | {
3 | "dotnetAcquisitionExtension.enableTelemetry": false,
4 | "cSpell.words": [
5 | "APPDATA",
6 | "aspnet",
7 | "aspnetcore",
8 | "distros",
9 | "dotnets",
10 | "HKCU",
11 | "HKEY",
12 | "norestart",
13 | "proccom",
14 | "programfiles",
15 | "REGHEXVALUE",
16 | "REGTYPE",
17 | "Republisher"
18 | ],
19 | "azure-pipelines.1ESPipelineTemplatesSchemaFile": true,
20 | "eslint.options": {
21 | "configFile": ".eslintrc.js"
22 | },
23 | "eslint.workingDirectories": [
24 | "./vscode-dotnet-runtime-library",
25 | "./vscode-dotnet-runtime-extension",
26 | "./vscode-dotnet-sdk-extension",
27 | "./sample"
28 | ]
29 | }
--------------------------------------------------------------------------------
/.vscodeignore:
--------------------------------------------------------------------------------
1 | .vscode/**
2 | .vscode-test/**
3 | .devcontainer/**
4 | node_modules/**
5 | dist/test/**
6 | src/**
7 | *.vsix
8 | packages/
9 | msbuild/**
10 | global.json
11 | nuget.config
--------------------------------------------------------------------------------
/1es-azure-pipeline.yml:
--------------------------------------------------------------------------------
1 | # Name: dotnet.vscode-dotnet-runtime
2 |
3 | # URL: https://dev.azure.com/dnceng/internal/_build?definitionId=656
4 |
5 | trigger:
6 | branches:
7 | include:
8 | - main
9 | tags:
10 | include:
11 | - SDK-v*
12 | - Runtime-v*
13 | pr:
14 | autoCancel: false
15 | branches:
16 | include:
17 | - '*'
18 |
19 | variables:
20 | - name: is-runtime-release
21 | value: $[startsWith(variables['Build.SourceBranch'], 'refs/tags/Runtime-v')]
22 | - name: is-sdk-release
23 | value: $[startsWith(variables['Build.SourceBranch'], 'refs/tags/SDK-v')]
24 | - name: Codeql.Enabled
25 | value: true
26 | - name: MicroBuildOutputFolderOverride
27 | value: '$(Agent.TempDirectory)'
28 |
29 | resources:
30 | repositories:
31 | - repository: 1esPipelines
32 | type: git
33 | name: 1ESPipelineTemplates/1ESPipelineTemplates
34 | ref: refs/tags/release
35 |
36 | parameters:
37 | - name: pools
38 | type: object
39 | default:
40 | - name: NetCore1ESPool-Internal
41 | image: 1es-windows-2022
42 | os: windows
43 | emoji: 🪟
44 | - name: NetCore1ESPool-Internal
45 | image: 1es-ubuntu-2204
46 | os: linux
47 | emoji: 🐧
48 | - name: Azure Pipelines
49 | image: macOS-latest
50 | os: macOS
51 | emoji: 🍎
52 | - name: SignType
53 | displayName: Sign type
54 | type: string
55 | default: Test
56 | values: [ 'Test', 'Real' ]
57 |
58 | extends:
59 | template: v1/1ES.Official.PipelineTemplate.yml@1esPipelines
60 | parameters:
61 | sdl:
62 | sourceAnalysisPool:
63 | name: NetCore1ESPool-Internal
64 | image: 1es-windows-2022
65 | os: windows
66 | sbom:
67 | enabled: false # SBOM requires a special setup for node.js projects to ensure all dependencies are included.
68 | policheck:
69 | enabled: true
70 | exclusionsFile: $(System.DefaultWorkingDirectory)\PoliCheckExclusions.xml
71 | tsa:
72 | enabled: true
73 | componentgovernance:
74 | ignoreDirectories: '.vscode-test/**'
75 | stages:
76 | - stage: Internal
77 | jobs:
78 | - ${{ each image in parameters.pools }}:
79 | - template: pipeline-templates/build-test.yaml@self
80 | parameters:
81 | pool:
82 | name: ${{ image.name }}
83 | image: ${{ image.image }}
84 | os: ${{ image.os }}
85 | emoji: ${{ image.emoji }}
86 | useOneEngineeringPool: true
87 | - template: pipeline-templates/upstream-verify.yaml@self
88 | parameters:
89 | pool:
90 | name: Azure Pipelines
91 | image: macOS-latest
92 | os: macOS
93 | useOneEngineeringPool: true
94 | - template: pipeline-templates/lint.yaml@self
95 | parameters:
96 | pool:
97 | name: Azure Pipelines
98 | image: macOS-latest
99 | os: macOS
100 | useOneEngineeringPool: true
101 | - template: pipeline-templates/package-vsix.yaml@self
102 | parameters:
103 | pool:
104 | name: NetCore1ESPool-Internal
105 | image: 1es-windows-2022
106 | os: windows
107 | useOneEngineeringPool: true
108 | SignType: ${{ parameters.SignType }}
109 | - template: pipeline-templates/sbom.yaml@self
110 | parameters:
111 | pool:
112 | name: NetCore1ESPool-Internal
113 | image: 1es-windows-2022
114 | os: windows
115 | useOneEngineeringPool: true
116 |
--------------------------------------------------------------------------------
/1pr-azure-pipeline.yml:
--------------------------------------------------------------------------------
1 | # Name: dotnet.vscode-dotnet-runtime
2 | # URL: https://dev.azure.com/dnceng-public/public/_build?definitionId=60
3 |
4 | trigger:
5 | branches:
6 | include:
7 | - main
8 | tags:
9 | include:
10 | - SDK-v*
11 | - Runtime-v*
12 | pr:
13 | autoCancel: false
14 | branches:
15 | include:
16 | - '*'
17 |
18 | variables:
19 | - name: Codeql.Enabled
20 | value: true
21 |
22 | # The public PR pool schema is different from the 1ES one. We use 'vmImage' which is a default azure pipeline schema. 'os' and 'name' have nothing to do with image selection here.
23 | # 1ES uses 'image' but defining an image this way using our public pools duseOneEngineeringPool not work as they aren't configured this way.
24 | # We can later add the flag 'useOneEngineeringPool' or one engineering system: false or true in all tasks to determine if we use vmImage or a 1es pool object.
25 | parameters:
26 | - name: pools
27 | type: object
28 | default:
29 | - name: NetCore-Public
30 | vmImage: windows-latest
31 | os: windows
32 | emoji: 🪟
33 | - name: NetCore-Public
34 | vmImage: ubuntu-latest
35 | os: linux
36 | emoji: 🐧
37 | - name: NetCore-Public
38 | vmImage: macOS-latest
39 | os: macOS
40 | emoji: 🍎
41 |
42 | stages:
43 | - stage: o # o is just used so it looks like a bullet point in the output of devops
44 | jobs:
45 | - ${{ each image in parameters.pools }}:
46 | - template: pipeline-templates/build-test.yaml
47 | parameters:
48 | pool:
49 | vmImage: ${{ image.vmImage }}
50 | os: ${{ image.os }}
51 | emoji: ${{ image.emoji }}
52 | useOneEngineeringPool: false
53 | - template: pipeline-templates/upstream-verify.yaml
54 | parameters:
55 | pool:
56 | vmImage: macOS-latest
57 | os: macOS
58 | useOneEngineeringPool: false
59 | - template: pipeline-templates/lint.yaml
60 | parameters:
61 | pool:
62 | vmImage: macOS-latest
63 | os: macOS
64 | useOneEngineeringPool: false
65 | - template: pipeline-templates/package-vsix.yaml
66 | parameters:
67 | pool:
68 | vmImage: windows-latest
69 | os: windows
70 | useOneEngineeringPool: false
71 | SignType: Test
72 |
--------------------------------------------------------------------------------
/CODE-OF-CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Code of Conduct
2 |
3 | This project has adopted the code of conduct defined by the Contributor Covenant
4 | to clarify expected behavior in our community.
5 |
6 | For more information, see the [.NET Foundation Code of Conduct](https://dotnetfoundation.org/code-of-conduct).
7 |
--------------------------------------------------------------------------------
/CODE_OWNERS.txt:
--------------------------------------------------------------------------------
1 | # CODEOWNERS file per https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
2 |
3 | # Default owners
4 | * @dotnet/dotnet-cli
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | See [Contributing](Documentation/contributing.md) for information about coding styles, source structure, making pull requests, and more.
4 |
--------------------------------------------------------------------------------
/Documentation/adding-distros.md:
--------------------------------------------------------------------------------
1 | # Adding Custom Distros
2 |
3 | Our initial support for automated .NET installs on Linux includes Ubuntu and Red Hat Enterprise Linux distros. Microsoft has first-party support for these distros as well as a few others, which you can learn more about at our [compatibility documentation](https://github.com/dotnet/core/blob/main/release-notes/8.0/supported-os.md#linux).
4 |
5 |
6 |
7 | While we plan on adding more distros in the future to meet the same support policy as [VS Code](https://code.visualstudio.com/docs/setup/linux), we are happy to review PRs that add support for more distros. Only a few changes are required, which we will describe here. We are open to hearing your feedback on https://github.com/dotnet/vscode-dotnet-runtime/issues.
8 |
9 |
10 | # Steps to Add Support for your Distro
11 |
12 | ### Edit the distro-support.json file
13 |
14 | We have a distro-support.json file which contains all of the commands needed to run dotnet. This file also contains the potential for 'preinstallCommands' necessary to install Microsoft feeds if the distro feed does not automatically include dotnet for certain versions.
15 |
16 | Please see https://github.com/dotnet/vscode-dotnet-runtime/blob/main/Documentation/json-schema/distro-support-schema.json for the schema of the JSON which explains each command, and edit https://github.com/dotnet/vscode-dotnet-runtime/blob/main/vscode-dotnet-runtime-library/distro-data/distro-support.json.
17 |
18 | ### Add your distro to the list of known distros
19 |
20 | You will need to update the enumeration of known distros in the 'DistroProviderFactory' here https://github.com/dotnet/vscode-dotnet-runtime/blob/2c4ca303131ab596ae429066bac3caf10e1de5d9/vscode-dotnet-runtime-library/src/Acquisition/LinuxVersionResolver.ts#L176C5-L176C13.
21 |
22 | You will have to create a 'DistroSDKProvider' class for your Distro, such as https://github.com/dotnet/vscode-dotnet-runtime/blob/main/vscode-dotnet-runtime-library/src/Acquisition/RedHatDistroSDKProvider.ts. But the implementation can all be inherited, unless the distro requires special logic.
23 |
24 | ### Implement any special functionality for your distro that differs from what's already implemented.
25 |
26 | Most of the functionality should be the same, but if your distro needs custom logic, you will need to implement it in a 'DistroSDKProvider'.
27 |
28 | ## Example
29 |
30 | If you'd like to see how Red Hat was initially added, you can look at this PR https://github.com/dotnet/vscode-dotnet-runtime/pull/1500/files. (Some of the custom implementation added during this time is not even needed anymore.)
31 |
32 | # Final Steps
33 |
34 | Submit a PR and ping our team @dotnet/dotnet-cli.
35 | Please include at minimum a screenshot of your code working on the distro as well as a set of tests to prove that the change is successful. Thank you.
36 |
--------------------------------------------------------------------------------
/Documentation/copyright.md:
--------------------------------------------------------------------------------
1 | Copyright
2 | =========
3 |
4 | The .NET Core copyright is held by ".NET Foundation and Contributors".
5 |
6 | The [.NET Foundation](http://www.dotnetfoundation.org/) is an independent organization that encourages open development and collaboration around the .NET ecosystem.
7 |
8 | Source License
9 | --------------
10 |
11 | The .NET Core project uses multiple licenses for the various project repositories.
12 |
13 | - The [MIT License](https://opensource.org/licenses/MIT) is used by most repositories for [code](https://github.com/dotnet/coreclr/).
14 | - The [Apache 2 License](https://opensource.org/licenses/Apache-2.0) is also used by some projects for [code](https://github.com/dotnet/roslyn/).
15 | - The [Creative Commons Attribution 4.0 International Public License (CC-BY)](https://creativecommons.org/licenses/by/4.0/) is used for [documentation](https://github.com/dotnet/docs/) and [swag](https://github.com/dotnet/swag).
16 |
17 | Binary License
18 | --------------
19 |
20 | .NET Core distributions are licensed with a variety of licenses, dependent on the content. By default, the MIT license is used, the exact same as the [source license](https://github.com/dotnet/core/blob/main/LICENSE.TXT), with the same copyright holder. There are some cases where that isn't possible because a given component includes a proprietary Microsoft binary. This is typically only the case for Windows distributions.
21 |
22 | The following rules are used for determining the binary license:
23 |
24 | - .NET Core binary distributions (zips, nuget packages, …) are licensed as MIT (identical to the [.NET Core source license](https://github.com/dotnet/core/blob/main/LICENSE.TXT)).
25 | - The license link (if there is one) should point to the repository where the file came from, for example: [dotnet/corefx](https://github.com/dotnet/corefx/blob/main/LICENSE.TXT).
26 | - If the contained binaries are built from multiple .NET Core repositories, the license should point to [dotnet/core](https://github.com/dotnet/core/blob/main/LICENSE.TXT).
27 | - If the contents are not 100% open source, the distribution should be licensed with the [.NET Library license](https://www.microsoft.com/net/dotnet_library_license.htm).
28 | - It is OK for licensing to be asymmetric for a single distribution type. For example, it’s possible that the .NET Core SDK distribution might be fully open source for Linux but include a closed-source component on Windows. In this case, the SDK would be licensed as MIT on Linux and use the .NET Library License on Windows. It is better to have more open licenses than less.
29 | - It is OK for the source and binary licenses not to match. For example, the source might be Apache 2 but ships as an MIT binary. The third party notices file should capture the Apache 2 license. This only works for a permissive licenses, however, we have limited the project to that class of licenses already. The value of this approach is that binary licenses are uniform.
30 |
31 | Patents
32 | -------
33 |
34 | Microsoft has issued a [Patent Promise for .NET Libraries and Runtime Components](https://github.com/dotnet/coreclr/blob/main/PATENTS.TXT).
35 |
--------------------------------------------------------------------------------
/Documentation/dev-spec.md:
--------------------------------------------------------------------------------
1 | # .NET Runtime Acquisition Strategy
2 |
3 | ## Common Among All Scenarios
4 |
5 | - Users (extension authors) ensure that they have a runtime installed by calling the `acquire` command, providing a Major.Minor version to install.
6 | - Users are expected to call us on extension startup to ensure that the runtime exists.
7 | - Downloaded runtimes are stored in [extension global storage](https://code.visualstudio.com/api/extension-capabilities/common-capabilities#data-storage).
8 |
9 | ## Scenarios
10 |
11 | ### First Acquisition
12 |
13 | - Resolve version by fetching release.json
14 | - If we are offline, we will fail here because the user also will not be able to download a runtime offline.
15 | - Check if version has been installed previously or is currently being installed
16 | - Fetch dotnet-install script
17 | - Install runtime via script
18 | - Validate installation was successful
19 | - Return path to runtime
20 |
21 | ### Subsequent Acquisitions (No Runtime Patches)
22 |
23 | - Resolve version with the cached release.json
24 | - We will update release.json in the background. If we are offline this will fail silently, which is fine as we can use the cached version.
25 | - Check if version has been installed previously or is currently being installed
26 | - As the resolved version is already installed, return path to runtime
27 |
28 | Note: This scenario can be conducted offline successfully.
29 |
30 | ### Subsequent Acquisitions (Runtime Patche Released)
31 |
32 | - Resolve version with the cached release.json
33 | - We will update release.json in the background.
34 | - **Note**: For efficiency, we do not block on release.json acquisition. This means that we may not install the most updated runtime until the following acquisition (once the release.json with the update has been acquired and cached).
35 | - Check if version has been installed previously or is currently being installed
36 | - Install runtime via cached install script
37 | - We will update the install script in the background. If we are offline this will fail silently.
38 | - Validate installation was successful
39 | - Return path to runtime
40 |
--------------------------------------------------------------------------------
/Documentation/example.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet/vscode-dotnet-runtime/9d40cb68b5a08530b000b70b0ff02ec2067d851a/Documentation/example.gif
--------------------------------------------------------------------------------
/Documentation/release.md:
--------------------------------------------------------------------------------
1 | See a copy of this file in the `internal-documentation` branch in our internal repository. Or instead, check out our team one note's 'VSCode Extension' --> 'release.md' file for further information.
--------------------------------------------------------------------------------
/Documentation/troubleshooting-runtime.md:
--------------------------------------------------------------------------------
1 | # Troubleshooting Issues with the .NET Install Tool
2 |
3 | ## Install Script Timeouts
4 |
5 | Please note that, depending on your network speed, installing the .NET Core runtime might take some time. By default, the installation terminates unsuccessfully if it takes longer than 10 minutes to finish. If you believe this is too little (or too much) time to allow for the download, you can change the timeout value by setting `dotnetAcquisitionExtension.installTimeoutValue` to a custom value.
6 |
7 | Learn more about configuring Visual Studio Code settings [here](https://code.visualstudio.com/docs/getstarted/settings) and see below for an example of a custom timeout in a `settings.json` file. In this example the custom timeout value is 180 seconds, or 3 minutes.
8 |
9 | ```json
10 | {
11 | "dotnetAcquisitionExtension.installTimeoutValue": 180
12 | }
13 | ```
14 |
15 | ## Windows 7 Failures
16 |
17 | The .NET Install Tool requires TLS 1.2 to be enabled in order to install .NET. For more information on TLS1.2, see [the documentation](https://docs.microsoft.com/mem/configmgr/core/plan-design/security/enable-tls-1-2-client).
18 |
19 | ## Manually Installing .NET
20 |
21 | If .NET installation is failing or you want to reuse an existing installation of .NET, you can use the `dotnetAcquisitionExtension.existingDotnetPath` setting. .NET can be manually installed from [the .NET website](https://aka.ms/dotnet-core-download). To direct this extension to that installation, update your settings with the extension ID and the path as illustrated below.
22 |
23 | #### Windows
24 |
25 | ```json
26 | "dotnetAcquisitionExtension.existingDotnetPath": [
27 | {"extensionId": "msazurermtools.azurerm-vscode-tools", "path": "C:\\Program Files\\dotnet\\dotnet.exe"}
28 | ]
29 | ```
30 |
31 | #### Mac
32 | ```json
33 | "dotnetAcquisitionExtension.existingDotnetPath": [
34 | {"extensionId": "msazurermtools.azurerm-vscode-tools", "path": "/usr/local/share/dotnet/dotnet"}
35 | ]
36 | ```
37 |
38 | ## Other Issues
39 |
40 | Haven't found a solution? Check out our [open issues](https://github.com/dotnet/vscode-dotnet-runtime/issues). If you don't see your issue there, please file a new issue by evoking the `.NET Install Tool: Report an issue with the .NET Install Tool` command from Visual Studio Code.
41 |
--------------------------------------------------------------------------------
/Documentation/troubleshooting-sdk.md:
--------------------------------------------------------------------------------
1 | # Troubleshooting Issues with .NET SDK Install Tool
2 |
3 | ## Unable to add to PATH
4 |
5 | To manually configure the `PATH`, see instructions by OS below. If you are still unable to add to the PATH environment variable you can still use the SDK by specifying the entire path to the executable. That is, instead of simply typing `dotnet` on the command line you can specify the full path that is outputted upon install.
6 |
7 | Please note that system environment variables may not take effect until after machine restart. If you believe setting the `PATH` was successful but the `dotnet` command is still not recognized on the command line, please restart your computer and try again.
8 |
9 | ### Windows
10 |
11 | To manually set the PATH, open the control panel and go to `Edit the system environment variables`. Select the `Advanced` tab, the `Environment Variables...` button, and find the `Path` variable in the list of user variables. Select `Edit`, `New`, and paste the path to the directory containing the dotnet executable, for example `C:\Users\user\AppData\Roaming\.dotnet\version`.
12 |
13 | ### Mac and Linux
14 |
15 | To manually set the PATH, edit your `.bash_profile` file to include the following line with `{ .NET Path }` replaced by the path to the directory containing the dotnet executable.
16 |
17 | ```
18 | PATH=$PATH:{ .NET Path }
19 | ```
20 |
21 | ## Install Script Timeouts
22 |
23 | Please note that, depending on your network speed, installing the .NET SDK might take some time. By default, the installation terminates unsuccessfully if it takes longer than 10 minutes to finish. If you believe this is too little (or too much) time to allow for the download, you can change the timeout value by setting `dotnetSDKAcquisitionExtension.installTimeoutValue` to a custom value.
24 |
25 | Learn more about configuring Visual Studio Code settings [here](https://code.visualstudio.com/docs/getstarted/settings) and see below for an example of a custom timeout in a `settings.json` file. In this example the custom timeout value is 300 seconds, or 5 minutes.
26 |
27 | ```json
28 | {
29 | "dotnetSDKAcquisitionExtension.installTimeoutValue": 300
30 | }
31 | ```
32 |
33 | ## The extension thinks you are offline with error response of 400 or 407, and you have a proxy.
34 |
35 | This is a known issue with axios, the system we use to make web-requests.
36 | The requests we make need to be routed through the proxy. We have logic to try to detect your proxy automatically.
37 | If your proxy does not get detected by us, please try adding it here.
38 |
39 | Note: GFW / China also blocks some of our requests, which may be why our extension thinks you are offline or times out.
40 |
41 | You can add the proxy in the extension settings like following the advice above for timeouts.
42 | ```json
43 | {
44 | "dotnetSDKAcquisitionExtension.proxyUrl": "https://your_proxy_url:port"
45 | }
46 | ```
47 |
48 | ## Other Issues
49 |
50 | Haven't found a solution? Check out our [open issues](https://github.com/dotnet/vscode-dotnet-runtime/issues). If you don't see your issue there, please file a new issue by evoking the `.NET SDK Install Tool: Report an issue with the .NET SDK Install Tool` command from Visual Studio Code.
51 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) .NET Foundation, Microsoft and Contributors
4 |
5 | All rights reserved.
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in all
15 | copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | SOFTWARE.
24 |
--------------------------------------------------------------------------------
/PoliCheckExclusions.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | NODE_MODULES|.STORE
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # .NET Runtime and SDK Installation Tools
2 |
3 | This repo contains two VS Code extensions, [vscode-dotnet-runtime](vscode-dotnet-runtime-extension/README.md) and [vscode-dotnet-sdk](vscode-dotnet-sdk-extension/README.md). The [vscode-dotnet-runtime](vscode-dotnet-runtime-extension/README.md) can be used to install the .NET runtime and is meant to be leveraged by other extensions which depend on the runtime. The [vscode-dotnet-sdk](vscode-dotnet-sdk-extension/README.md) is a special install for internal features and not designed to be used by other extensions because it will conflict with existing SDK installations on the users machine.
4 |
5 | ## Contributing to Repository
6 |
7 | Looking for something to work on? The list
8 | of [up-for-grabs issues](https://github.com/dotnet/vscode-dotnet-runtime/labels/up-for-grabs) is a great place to start.
9 |
10 | Please read the following documents to get started.
11 |
12 | * [Contributing Guide](Documentation/contributing.md)
13 | * [Contributing Workflow](Documentation/contributing-workflow.md)
14 |
15 | This project has adopted the code of conduct defined by the [Contributor Covenant](http://contributor-covenant.org/)
16 | to clarify expected behavior in our community. For more information, see the [.NET Foundation Code of Conduct](http://www.dotnetfoundation.org/code-of-conduct).
17 |
18 | ## Building
19 |
20 | ### Requirements
21 |
22 | - Node.js + npm
23 | - VSCode
24 |
25 | ### Running the sample
26 |
27 | 1. Run the build script at the root of the repo (`build.sh` or `build.cmd`).
28 | 2. Open the repo's [workspace](vscode-dotnet-runtime.code-workspace) in VSCode
29 | 3. Run the `Run Sample Extension` configuration in VSCode
30 | 4. In the launched experimental instance open the command pallete and run the `Sample: Run a dynamically acquired .NET Core Hello World App`.
31 |
32 | ## .NET Foundation
33 |
34 | .NET Core for VSCode is a [.NET Foundation](https://www.dotnetfoundation.org/projects) project.
35 |
36 | See the [.NET home repo](https://github.com/Microsoft/dotnet) to find other .NET-related projects.
37 |
38 | ## License
39 |
40 | .NET Core (including this repo) is licensed under the MIT license.
41 |
--------------------------------------------------------------------------------
/SUPPORT.md:
--------------------------------------------------------------------------------
1 | # Support
2 | ## How to file issues and get help
3 | This project uses [GitHub Issues](https://github.com/dotnet/vscode-dotnet-runtime/issues) to [track bugs](https://github.com/dotnet/vscode-dotnet-runtime/issues/new?assignees=&labels=&projects=&template=bug-report--vs-code-runtime-extension.md&title=) and [feature requests](https://github.com/dotnet/vscode-dotnet-runtime/issues/new?assignees=&labels=&projects=&template=feature-request--vs-code-runtime-extension.md&title=). Please search the existing issues before filing new issues to avoid duplicates. For new issues, file your bug or feature request as a new Issue.
4 |
5 | For help and questions about using this project, please see the [README](https://github.com/dotnet/vscode-dotnet-runtime/blob/main/README.md) and [C# Dev Kit FAQ](https://code.visualstudio.com/docs/csharp/cs-dev-kit-faq) for more information.
6 |
7 | ## Microsoft Support Policy
8 | Support for this project is limited to the resources listed above.
9 |
--------------------------------------------------------------------------------
/build.cmd:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 | PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' default-build %*; exit $LASTEXITCODE"
--------------------------------------------------------------------------------
/build.ps1:
--------------------------------------------------------------------------------
1 | $errorColor = "Red"
2 | $successColor = "Green"
3 |
4 |
5 | #################### Download backup install scripts ####################
6 | function DownloadInstallScripts() {
7 | Invoke-WebRequest https://dot.net/v1/dotnet-install.ps1 -OutFile "./vscode-dotnet-runtime-library/install scripts/dotnet-install.ps1"
8 | Invoke-WebRequest https://dot.net/v1/dotnet-install.sh -OutFile "./vscode-dotnet-runtime-library/install scripts/dotnet-install.sh"
9 | }
10 |
11 | try
12 | {
13 | DownloadInstallScripts
14 | }
15 | catch
16 | {
17 | $exceptionMessage = $_.Exception.Message
18 | Write-Host "Failed to install scripts, retrying: $exceptionMessage"
19 | DownloadInstallScripts
20 | }
21 | if ($?) {
22 | Write-Host "`nBundled dotnet-install scripts" -ForegroundColor $successColor
23 | } else {
24 | Write-Host "`nFailed to bundle dotnet-install scripts" -ForegroundColor $errorColor
25 | }
26 | icacls "./vscode-dotnet-runtime-library/install scripts/dotnet-install.ps1" /grant:r "users:(RX)" /C
27 | icacls "./vscode-dotnet-runtime-library/install scripts/dotnet-install.sh" /grant:r "users:(RX)" /C
28 |
29 | #################### Compile library ####################
30 | pushd vscode-dotnet-runtime-library
31 | if (Test-Path node_modules) { rm -r -force node_modules }
32 | npm ci
33 | npm run compile
34 |
35 | if (! $?)
36 | {
37 | Write-Host "`nBuild failed!" -ForegroundColor $errorColor
38 | exit 1
39 | }
40 | popd
41 |
42 | #################### Compile runtime extension ####################
43 | pushd vscode-dotnet-runtime-extension
44 | if (Test-Path node_modules) { rm -r -force node_modules }
45 | npm ci
46 | npm run compile
47 |
48 | if (! $?)
49 | {
50 | Write-Host "`nBuild failed!" -ForegroundColor $errorColor
51 | exit 1
52 | }
53 | popd
54 |
55 | #################### Compile SDK extension ####################
56 | pushd vscode-dotnet-sdk-extension
57 | if (Test-Path node_modules) { rm -r -force node_modules }
58 | npm ci
59 | npm run compile
60 |
61 | if (! $?)
62 | {
63 | Write-Host "`nBuild failed!" -ForegroundColor $errorColor
64 | exit 1
65 | }
66 | popd
67 |
68 | #################### Compile sample extension ####################
69 | pushd sample
70 | if (Test-Path node_modules) { rm -r -force node_modules }
71 | npm ci
72 | npm run compile
73 |
74 | if (! $?)
75 | {
76 | Write-Host "`nBuild failed!" -ForegroundColor $errorColor
77 | exit 1
78 | }
79 | popd
80 |
81 | #################### Copy Library Artifacts ####################
82 | & "$(Split-Path $MyInvocation.MyCommand.Path)/mock-webpack.ps1"
83 |
84 | Write-Host "Build Succeeded" -ForegroundColor $successColor
85 |
86 | #################### Install Signing Tool ####################
87 |
88 | try
89 | {
90 | $InstallNuGetPkgScriptPath = ".\signing\Install-NuGetPackage.ps1"
91 | $nugetVerbosity = 'quiet'
92 | if ($Verbose) { $nugetVerbosity = 'normal' }
93 | $MicroBuildPackageSource = 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json'
94 | if ($Signing)
95 | {
96 | Write-Host "Installing MicroBuild signing plugin" -ForegroundColor $successColor
97 | Invoke-Expression "& `"$InstallNuGetPkgScriptPath`" MicroBuild.Plugins.Signing -source $MicroBuildPackageSource -Verbosity $nugetVerbosity"
98 | $EnvVars['SignType'] = "Test"
99 | }
100 |
101 | & ".\signing\Set-EnvVars.ps1" -Variables $EnvVars -PrependPath $PrependPath | Out-Null
102 | } catch {
103 | Write-Host "Failed to install signing tool" -ForegroundColor $errorColor
104 | Write-Host $_.Exception.Message
105 | }
--------------------------------------------------------------------------------
/build.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | RED=`tput setaf 1`
3 | GREEN=`tput setaf 2`
4 | NC=`tput sgr0`
5 |
6 | echo ""
7 | echo "----------- Bundling Install Scripts -----------"
8 | echo ""
9 | curl https://dot.net/v1/dotnet-install.ps1 --retry 2 -o "./vscode-dotnet-runtime-library/install scripts/dotnet-install.ps1"
10 | curl https://dot.net/v1/dotnet-install.sh --retry 2 -o "./vscode-dotnet-runtime-library/install scripts/dotnet-install.sh"
11 | if [ $? -eq 0 ];
12 | then
13 | echo ""
14 | echo "${GREEN}Bundled install scripts${NC}"
15 | else
16 | echo ""
17 | echo "${RED}Unable to bundle install scripts${NC}"
18 | fi
19 | chmod +x "./vscode-dotnet-runtime-library/install scripts/dotnet-install.ps1"
20 | chmod +x "./vscode-dotnet-runtime-library/install scripts/dotnet-install.sh"
21 |
22 | echo ""
23 | echo "----------- Compiling vscode-dotnet-runtime-library -----------"
24 | echo ""
25 | pushd vscode-dotnet-runtime-library
26 | rm -rf node_modules
27 | npm ci
28 | npm run compile
29 |
30 | if [ $? -ne 0 ];
31 | then
32 | echo ""
33 | echo "${RED}Build failed!${NC}"
34 | exit 1
35 | fi
36 | popd
37 |
38 | echo ""
39 | echo "----------- Compiling vscode-dotnet-runtime-extension -----------"
40 | echo ""
41 | pushd vscode-dotnet-runtime-extension
42 | rm -rf node_modules
43 | npm ci
44 | npm run compile
45 |
46 | if [ $? -ne 0 ];
47 | then
48 | echo ""
49 | echo "${RED}Build failed!${NC}"
50 | exit 1
51 | fi
52 | popd
53 |
54 | echo ""
55 | echo "----------- Compiling vscode-dotnet-sdk-extension -----------"
56 | echo ""
57 | pushd vscode-dotnet-sdk-extension
58 | rm -rf node_modules
59 | npm ci
60 | npm run compile
61 |
62 | if [ $? -ne 0 ];
63 | then
64 | echo ""
65 | echo "${RED}Build failed!${NC}"
66 | exit 1
67 | fi
68 | popd
69 |
70 | echo ""
71 | echo "----------- Compiling sample -----------"
72 | echo ""
73 | pushd sample
74 | rm -rf node_modules
75 | npm ci
76 | npm run compile
77 |
78 | if [ $? -ne 0 ];
79 | then
80 | echo ""
81 | echo "${RED}Build failed!${NC}"
82 | exit 1
83 | fi
84 | popd
85 |
86 | /bin/bash ./mock-webpack.sh
87 |
88 | echo ""
89 | echo "${GREEN}Build succeeded!${NC}"
90 | exit 0
91 |
--------------------------------------------------------------------------------
/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "msbuild-sdks": {
3 | "Microsoft.Build.NoTargets": "3.7.0"
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/images/dotnetIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet/vscode-dotnet-runtime/9d40cb68b5a08530b000b70b0ff02ec2067d851a/images/dotnetIcon.png
--------------------------------------------------------------------------------
/mock-webpack.ps1:
--------------------------------------------------------------------------------
1 | # The library doesn't get webpacked, but it needs the copy of items that would normally be webpacked
2 | # ... into the SDK or Runtime Extension for it to run in local dev scenarios.
3 | Copy-Item ".\vscode-dotnet-runtime-library\distro-data\" -Destination ".\vscode-dotnet-runtime-library\dist\Acquisition\" -Recurse -Force
4 | Copy-Item ".\vscode-dotnet-runtime-library\install scripts\" -Destination ".\vscode-dotnet-runtime-library\dist\utils\" -Recurse -Force
5 |
--------------------------------------------------------------------------------
/mock-webpack.sh:
--------------------------------------------------------------------------------
1 | echo ""
2 | echo "----------- Copying Library Webpacked Dependencies -----------"
3 | echo "" # See the build.ps1 for more details on why we do this
4 | cp -r ./vscode-dotnet-runtime-library/distro-data ./vscode-dotnet-runtime-library/dist/Acquisition
5 | cp -r "./vscode-dotnet-runtime-library/install scripts" ./vscode-dotnet-runtime-library/dist/Utils
6 |
--------------------------------------------------------------------------------
/msbuild/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | $(MSBuildThisFileDirectory)../
4 |
5 |
6 |
--------------------------------------------------------------------------------
/msbuild/Directory.Build.rsp:
--------------------------------------------------------------------------------
1 | #------------------------------------------------------------------------------
2 | # This file contains command-line options that MSBuild will process as part of
3 | # every build, unless the "/noautoresponse" switch is specified.
4 | #
5 | # MSBuild processes the options in this file first, before processing the
6 | # options on the command line. As a result, options on the command line can
7 | # override the options in this file. However, depending on the options being
8 | # set, the overriding can also result in conflicts.
9 | #
10 | # NOTE: The "/noautoresponse" switch cannot be specified in this file, nor in
11 | # any response file that is referenced by this file.
12 | #------------------------------------------------------------------------------
13 | /nr:false
14 | /m
15 | /verbosity:minimal
16 | /clp:Summary;ForceNoAlign
17 |
--------------------------------------------------------------------------------
/msbuild/Directory.Packages.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | true
5 | true
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/msbuild/signJs/signJs.proj:
--------------------------------------------------------------------------------
1 |
2 |
3 | netstandard2.0
4 | false
5 | false
6 | true
7 | false
8 | $(MSBuildProjectDirectory)\$(JSOutputPath)\
9 | true
10 |
11 |
12 |
13 | test
14 |
15 |
16 |
17 |
18 | MicrosoftSHA2
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/msbuild/signVsix/signVsix.proj:
--------------------------------------------------------------------------------
1 |
2 |
3 | netstandard2.0
4 | false
5 | false
6 | true
7 | false
8 | $(RepoRoot)packages\
9 |
10 |
11 |
12 | VsixSHA2
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/nuget.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vscode-dotnet-runtime",
3 | "repository": {
4 | "type": "git",
5 | "url": "https://github.com/dotnet/vscode-dotnet-runtime.git"
6 | },
7 | "bugs": {
8 | "url": "https://github.com/dotnet/vscode-dotnet-runtime/issues"
9 | },
10 | "license": "MIT",
11 | "author": "Microsoft Corporation",
12 | "scripts": {
13 | "compile-all": "build.cmd",
14 | "lint": "npx eslint@^8.57.0 -c .eslintrc.js --ext=.ts vscode-dotnet-runtime-library/src/**/*.ts vscode-dotnet-runtime-extension/src/**/*.ts --ignore-pattern \"**/test/\" --fix"
15 | },
16 | "dependencies": {
17 | "@typescript-eslint/eslint-plugin-tslint": "^7.0.2",
18 | "@vscode/vsce": "^2.26.1",
19 | "eslint-import-resolver-typescript": "^3.6.3",
20 | "eslint-plugin-import": "^2.30.0",
21 | "eslint-plugin-jsdoc": "^50.2.2",
22 | "eslint-plugin-prefer-arrow": "^1.2.3",
23 | "tslint": "^6.1.3",
24 | "typescript": "^5.5.4"
25 | },
26 | "devDependencies": {
27 | "@types/source-map-support": "^0.5.6",
28 | "@typescript-eslint/eslint-plugin": "^8.0.0",
29 | "@typescript-eslint/parser": "^8.0.0",
30 | "eslint": "^8.57.0",
31 | "eslint-config-prettier": "^9.1.0",
32 | "eslint-import-resolver-node": "^0.3.9",
33 | "eslint-plugin-prettier": "^5.2.1",
34 | "rimraf": "3.0.2"
35 | }
36 | }
--------------------------------------------------------------------------------
/packages/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
--------------------------------------------------------------------------------
/pipeline-templates/build-test.yaml:
--------------------------------------------------------------------------------
1 | parameters:
2 | pool: ''
3 |
4 | jobs:
5 | - job: ${{ parameters.pool.os }}_Build
6 | pool:
7 | ${{ if eq(parameters.useOneEngineeringPool, 'true') }}:
8 | ${{ parameters.pool }}
9 | ${{ else }}:
10 | vmImage: ${{ parameters.pool.vmImage }}
11 |
12 | displayName: '${{ parameters.pool.emoji }} ${{ parameters.pool.os }} Build and Test'
13 | templateContext:
14 | outputs:
15 | - output: pipelineArtifact
16 | displayName: '🌐 Publish Install Tool Logs'
17 | condition: always()
18 | targetPath: '$(Build.SourcesDirectory)/vscode-dotnet-runtime-extension/dist/test/functional/logs'
19 | artifactName: '${{ parameters.pool.os }} Install Tool logs-$(currentTimeStamp)'
20 | - output: pipelineArtifact
21 | displayName: '👜 Publish SDK Logs'
22 | condition: always()
23 | targetPath: '$(Build.SourcesDirectory)/vscode-dotnet-sdk-extension/dist/test/functional/logs'
24 | artifactName: '${{ parameters.pool.os }} SDK logs-$(currentTimeStamp)'
25 | steps:
26 | - template: install-node.yaml
27 | - pwsh: |
28 | $date=$(Get-Date -format yyyyMMdd-Hmmss)
29 | Write-Host "##vso[task.setvariable variable=currentTimeStamp]$date"
30 | displayName: '🕦 Getting timestamp for unique artifact names'
31 | - ${{ if eq(parameters.pool.os, 'windows') }}:
32 | - script: build.cmd
33 | displayName: 💻 Build Windows
34 | condition:
35 | - script: test.cmd
36 | displayName: 🔍 Test Windows
37 | - ${{ if eq(parameters.pool.os, 'linux') }}:
38 | - bash: |
39 | /usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
40 | echo ">>> Started xvfb"
41 | displayName: 🎮 Start xvfb
42 | - ${{ if or(eq(parameters.pool.os, 'macOS'), eq(parameters.pool.os, 'linux')) }}:
43 | - script: ./build.sh
44 | displayName: 🐧 Build Mac and Linux
45 | condition:
46 | - script: ./test.sh
47 | displayName: 🔎 Test Mac and Linux
48 | env: {DISPLAY: ':99.0'}
49 | - ${{ if ne(parameters.useOneEngineeringPool, 'true') }}:
50 | - task: PublishBuildArtifacts@1
51 | displayName: ♻️ Publish Public PR Logs
52 | inputs:
53 | pathtoPublish: '$(Build.SourcesDirectory)/vscode-dotnet-runtime-extension/dist/test/functional/logs'
54 | artifactName: 'logs'
55 | condition: always()
56 |
--------------------------------------------------------------------------------
/pipeline-templates/install-node.yaml:
--------------------------------------------------------------------------------
1 | steps:
2 | - task: UseNode@1
3 | inputs:
4 | version: '20.x'
5 | displayName: '⚛️ Install Node.js'
--------------------------------------------------------------------------------
/pipeline-templates/lint.yaml:
--------------------------------------------------------------------------------
1 | parameters:
2 | pool: ''
3 |
4 | jobs:
5 | - job: ESLint
6 | pool:
7 | ${{ if eq(parameters.useOneEngineeringPool, 'true') }}:
8 | ${{ parameters.pool }}
9 | ${{ else }}:
10 | vmImage: ${{ parameters.pool.vmImage }}
11 | displayName: '🧶 ESLint'
12 | steps:
13 | - template: install-node.yaml
14 | - script: ./build.sh
15 | displayName: 🐧 Build To Install Deps
16 | - bash: |
17 | npm ci eslint@^8.57.0 @typescript-eslint/parser@^8.0.0 @typescript-eslint/eslint-plugin@^8.0.0 --save-dev
18 | npm run lint
19 | displayName: 🧶 Run Lint
20 |
--------------------------------------------------------------------------------
/pipeline-templates/package-vsix.yaml:
--------------------------------------------------------------------------------
1 | parameters:
2 | pool: ''
3 | SignType: ''
4 |
5 | jobs:
6 | - job: ${{ parameters.pool.os }}_Package
7 | pool:
8 | ${{ if eq(parameters.useOneEngineeringPool, 'true') }}:
9 | ${{ parameters.pool }}
10 | ${{ else }}:
11 | vmImage: ${{ parameters.pool.vmImage }}
12 | displayName: '📦 Package and Publish'
13 | strategy:
14 | matrix:
15 | Runtime:
16 | dir-name: 'vscode-dotnet-runtime-extension'
17 | package-name: 'vscode-dotnet-runtime'
18 | templateContext:
19 | outputs:
20 | - output: pipelineArtifact
21 | displayName: '📂 Publish .VSIX'
22 | targetPath: '$(Build.ArtifactStagingDirectory)'
23 | artifactName: '$(dir-name)'
24 | steps:
25 | - template: install-node.yaml
26 | - bash: |
27 | if ([ $(is-sdk-release) = 'True' ] && [ $(package-name) = 'vscode-dotnet-sdk' ]) || ([ $(is-runtime-release) = 'True' ] && [ $(package-name) = 'vscode-dotnet-runtime' ]); then
28 | VERSION=`node -p "require('./package.json').version"`
29 | else
30 | VERSION_NUM=`node -p "require('./package.json').version"`
31 | VERSION="$VERSION_NUM"
32 | fi
33 | npm version $VERSION --allow-same-version
34 | echo "##vso[task.setvariable variable=version;isOutput=true]$VERSION"
35 | name: GetVersion
36 | displayName: '❓ Get Version'
37 | workingDirectory: $(dir-name)
38 | - ${{ if eq(parameters.useOneEngineeringPool, 'true') }}:
39 | - template: prepare-signing.yaml
40 | parameters:
41 | SignType: ${{ parameters.SignType }}
42 | - bash: |
43 | npm i -g rimraf
44 | npm i -g @vscode/vsce
45 | vsce package -o $(package-name)-$(GetVersion.version).vsix --ignoreFile ../.vscodeignore --yarn
46 | cp $(package-name)-$(GetVersion.version).vsix ../packages/$(package-name)-$(GetVersion.version).vsix
47 | displayName: 📦 Package Artifact
48 | workingDirectory: $(dir-name)
49 | env:
50 | SignType: ${{ parameters.SignType }}
51 | - script: dotnet build msbuild/signVsix -v:normal
52 | displayName: 🖊️ Sign VSIXes
53 | env:
54 | SignType: ${{ parameters.SignType }}
55 | - task: CmdLine@2
56 | displayName: 🤌 Rename Signed VSIX
57 | inputs:
58 | script: rename ".\packages\$(package-name)-$(GetVersion.version).vsix" $(package-name)-$(GetVersion.version)-signed.vsix
59 | - task: CopyFiles@2
60 | displayName: '📩 Copy Artifact'
61 | inputs:
62 | SourceFolder: '$(Build.SourcesDirectory)'
63 | Contents: '**\*.vsix'
64 | TargetFolder: '$(Build.ArtifactStagingDirectory)'
65 | flattenFolders: true
66 | - task: CopyFiles@2
67 | displayName: '🏗️ Copy Binlog'
68 | inputs:
69 | SourceFolder: '$(Build.SourcesDirectory)'
70 | Contents: '**\*.binlog'
71 | TargetFolder: '$(Build.ArtifactStagingDirectory)'
72 | flattenFolders: false
73 | - ${{ if eq(parameters.useOneEngineeringPool, 'true') }}:
74 | - template: publish.yaml
75 | parameters:
76 | pool: ${{ parameters.pool }}
77 | SignType: ${{ parameters.SignType }}
78 | version: $(GetVersion.version)
79 | useOneEngineeringPool: true
--------------------------------------------------------------------------------
/pipeline-templates/prepare-signing.yaml:
--------------------------------------------------------------------------------
1 | steps:
2 | - task: UseDotNet@2
3 | displayName: 🔮 Use .NET SDK
4 | inputs:
5 | packageType: sdk
6 | useGlobalJson: true
7 | # This is necessary whenever we want to publish/restore to an AzDO private feed
8 | # otherwise it'll complain about accessing a private feed.
9 | - task: NuGetAuthenticate@1
10 | displayName: '🔏 Authenticate to AzDO Feeds'
11 | - task: MicroBuildSigningPlugin@4
12 | displayName: 🔧 Install MicroBuild Signing Plugin
13 | inputs:
14 | signType: ${{ parameters.SignType }}
15 | zipSources: false
16 | feedSource: https://dnceng.pkgs.visualstudio.com/_packaging/MicroBuildToolset/nuget/v3/index.json
17 | env:
18 | SignType: ${{ parameters.SignType }}
19 | TeamName: DotNetCore
--------------------------------------------------------------------------------
/pipeline-templates/publish.yaml:
--------------------------------------------------------------------------------
1 | parameters:
2 | pool: ''
3 | SignType: ''
4 | useOneEngineeringPool: ''
5 |
6 | jobs:
7 | - job: waitForValidation
8 | displayName: ☁️ Wait for release approval
9 | pool: server
10 | timeoutInMinutes: 4320 # job times out in 3 days
11 | steps:
12 | - task: ManualValidation@0
13 | timeoutInMinutes: 4320
14 | inputs:
15 | instructions: 'Please validate that the release build has been tested, and resume to publish a new version'
16 | onTimeout: 'reject'
17 | - job: Publish
18 | pool:
19 | ${{ if eq(parameters.useOneEngineeringPool, 'true') }}:
20 | ${{ parameters.pool }}
21 | ${{ else }}:
22 | vmImage: ${{ parameters.pool.vmImage }}
23 | displayName: '🌐 Publish to Marketplace'
24 | dependsOn:
25 | - waitForValidation
26 | - ${{ parameters.pool.os }}_Package
27 | steps:
28 | - task: DownloadPipelineArtifact@2
29 | displayName: '⬇️ Download Packaged Extension'
30 | inputs:
31 | path: '$(System.ArtifactsDirectory)'
32 | - template: install-node.yaml
33 | - bash: |
34 | VERSION=`node -p "require('./package.json').version"`
35 | npm version $VERSION --allow-same-version
36 | echo "##vso[task.setvariable variable=version;isOutput=true]$VERSION"
37 | name: GetVersion
38 | displayName: '❓ Get Version'
39 | workingDirectory: 'vscode-dotnet-runtime-extension'
40 | - task: AzureCLI@2
41 | displayName: '🚀 Publish to Marketplace'
42 | inputs:
43 | azureSubscription: 'VSCode Marketplace Publishing'
44 | scriptType: "pscore"
45 | scriptLocation: 'inlineScript'
46 | workingDirectory: '$(System.ArtifactsDirectory)'
47 | inlineScript: |
48 | npm i -g --verbose @vscode/vsce
49 | $basePublishArgs = , "publish"
50 | $basePublishArgs += '--azure-credential'
51 | $basePublishArgs += '--packagePath'
52 | $publishArgs = $basePublishArgs + 'vscode-dotnet-runtime-$(GetVersion.version)-signed.vsix'
53 | If ("${{ parameters.SignType }}" -ne "Real") {
54 | Write-Host "With a test-signed build, the command to publish is printed instead of run."
55 | Write-Host "##[command]vsce $publishArgs"
56 | }
57 | Else {
58 | Write-Host "##[command]vsce $publishArgs"
59 | vsce @publishArgs
60 | }
--------------------------------------------------------------------------------
/pipeline-templates/sbom.yaml:
--------------------------------------------------------------------------------
1 | parameters:
2 | pool: ''
3 |
4 | jobs:
5 | - job: SBOM
6 | pool:
7 | ${{ if eq(parameters.useOneEngineeringPool, 'true') }}:
8 | ${{ parameters.pool }}
9 | ${{ else }}:
10 | vmImage: ${{ parameters.pool.vmImage }}
11 | displayName: 📝 SBOM Generation
12 | dependsOn:
13 | - ${{ parameters.pool.os }}_Build
14 | - ${{ parameters.pool.os }}_Package
15 | steps:
16 | - task: ManifestGeneratorTask@0
17 | displayName: 📃 SBOM generation
18 | inputs:
19 | BuildDropPath: $(System.DefaultWorkingDirectory)
20 | templateContext:
21 | outputs:
22 | - output: pipelineArtifact
23 | displayName: 📢 Publishing SBOM
24 | artifact: SBOM
25 | targetPath: $(System.DefaultWorkingDirectory)/_manifest
--------------------------------------------------------------------------------
/pipeline-templates/upstream-verify.yaml:
--------------------------------------------------------------------------------
1 | parameters:
2 | pool: ''
3 |
4 | jobs:
5 | - job: SyncPackageManagers
6 | pool:
7 | ${{ if eq(parameters.useOneEngineeringPool, 'true') }}:
8 | ${{ parameters.pool }}
9 | ${{ else }}:
10 | vmImage: ${{ parameters.pool.vmImage }}
11 | displayName: '♻️ Verify NPM & Yarn In-Sync [Local Copy of Target Branch Must Be Up to Date]'
12 | steps:
13 | - task: UsePythonVersion@0
14 | inputs:
15 | versionSpec: '3.x'
16 | addToPath: true
17 | architecture: 'x64'
18 | - task: PythonScript@0
19 | continueOnError: true
20 | inputs:
21 | scriptSource: 'filePath'
22 | scriptPath: 'dependency-verifier.py'
23 | arguments: '$(System.PullRequest.TargetBranch)'
--------------------------------------------------------------------------------
/sample/.npmrc:
--------------------------------------------------------------------------------
1 | registry=https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/
--------------------------------------------------------------------------------
/sample/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | // A launch configuration that compiles the extension and then opens it inside a new window
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | {
6 | "version": "0.2.0",
7 | "configurations": [{
8 | "name": "Run Sample Extension",
9 | "type": "extensionHost",
10 | "request": "launch",
11 | "runtimeExecutable": "${execPath}",
12 | "args": [
13 | "--extensionDevelopmentPath=${workspaceFolder}",
14 | "--disable-extensions"
15 | ],
16 | "outFiles": [
17 | "${workspaceFolder}/out/**/*.js"
18 | ],
19 | "preLaunchTask": "npm: watch"
20 | }
21 | ]
22 | }
23 |
--------------------------------------------------------------------------------
/sample/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.exclude": {
4 | "out": false // set this to true to hide the "out" folder with the compiled JS files
5 | },
6 | "search.exclude": {
7 | "out": true // set this to false to include "out" folder in search results
8 | },
9 | // Turn off tsc task auto detection since we have the necessary tasks as npm scripts
10 | "typescript.tsc.autoDetect": "off"
11 | }
--------------------------------------------------------------------------------
/sample/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | // See https://go.microsoft.com/fwlink/?LinkId=733558
2 | // for the documentation about the tasks.json format
3 | {
4 | "version": "2.0.0",
5 | "tasks": [
6 | {
7 | "type": "npm",
8 | "script": "watch",
9 | "problemMatcher": "$tsc-watch",
10 | "isBackground": true,
11 | "presentation": {
12 | "reveal": "never"
13 | },
14 | "group": {
15 | "kind": "build",
16 | "isDefault": true
17 | }
18 | }
19 | ]
20 | }
21 |
--------------------------------------------------------------------------------
/sample/HelloWorldConsoleApp/HelloWorldConsoleApp.deps.json:
--------------------------------------------------------------------------------
1 | {
2 | "runtimeTarget": {
3 | "name": ".NETCoreApp,Version=v2.2",
4 | "signature": "da39a3ee5e6b4b0d3255bfef95601890afd80709"
5 | },
6 | "compilationOptions": {},
7 | "targets": {
8 | ".NETCoreApp,Version=v2.2": {
9 | "HelloWorldConsoleApp/1.0.0": {
10 | "runtime": {
11 | "HelloWorldConsoleApp.dll": {}
12 | }
13 | }
14 | }
15 | },
16 | "libraries": {
17 | "HelloWorldConsoleApp/1.0.0": {
18 | "type": "project",
19 | "serviceable": false,
20 | "sha512": ""
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/sample/HelloWorldConsoleApp/HelloWorldConsoleApp.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet/vscode-dotnet-runtime/9d40cb68b5a08530b000b70b0ff02ec2067d851a/sample/HelloWorldConsoleApp/HelloWorldConsoleApp.dll
--------------------------------------------------------------------------------
/sample/HelloWorldConsoleApp/HelloWorldConsoleApp.runtimeconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "runtimeOptions": {
3 | "tfm": "netcoreapp2.2",
4 | "framework": {
5 | "name": "Microsoft.NETCore.App",
6 | "version": "2.2.0"
7 | }
8 | }
9 | }
--------------------------------------------------------------------------------
/sample/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) .NET Foundation, Microsoft and Contributors
4 |
5 | All rights reserved.
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in all
15 | copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | SOFTWARE.
24 |
--------------------------------------------------------------------------------
/sample/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "outDir": "out",
6 | "lib": [
7 | "es6"
8 | ],
9 | "sourceMap": true,
10 | "rootDir": "src",
11 | "strict": true /* enable all strict type-checking options */
12 | },
13 | "exclude": [
14 | "node_modules",
15 | ".vscode-test",
16 | "out"
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/sample/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tslint.json"
3 | }
--------------------------------------------------------------------------------
/signing/Get-NuGetTool.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Downloads the NuGet.exe tool and returns the path to it.
4 | .PARAMETER NuGetVersion
5 | The version of the NuGet tool to acquire.
6 | #>
7 | Param(
8 | [Parameter()]
9 | [string]$NuGetVersion='6.4.0'
10 | )
11 |
12 | $toolsPath = & "$PSScriptRoot\Get-TempToolsPath.ps1"
13 | $binaryToolsPath = Join-Path $toolsPath $NuGetVersion
14 | if (!(Test-Path $binaryToolsPath)) { $null = mkdir $binaryToolsPath }
15 | $nugetPath = Join-Path $binaryToolsPath nuget.exe
16 |
17 | if (!(Test-Path $nugetPath)) {
18 | Write-Host "Downloading nuget.exe $NuGetVersion..." -ForegroundColor Yellow
19 | (New-Object System.Net.WebClient).DownloadFile("https://dist.nuget.org/win-x86-commandline/v$NuGetVersion/NuGet.exe", $nugetPath)
20 | }
21 |
22 | return (Resolve-Path $nugetPath).Path
23 |
--------------------------------------------------------------------------------
/signing/Get-TempToolsPath.ps1:
--------------------------------------------------------------------------------
1 | if ($env:AGENT_TEMPDIRECTORY) {
2 | $path = "$env:AGENT_TEMPDIRECTORY\$env:BUILD_BUILDID"
3 | } elseif ($env:localappdata) {
4 | $path = "$env:localappdata\gitrepos\tools"
5 | } else {
6 | $path = "$PSScriptRoot\..\obj\tools"
7 | }
8 |
9 | if (!(Test-Path $path)) {
10 | New-Item -ItemType Directory -Path $Path | Out-Null
11 | }
12 |
13 | (Resolve-Path $path).Path
14 |
--------------------------------------------------------------------------------
/signing/Install-NuGetPackage.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Installs a NuGet package.
4 | .PARAMETER PackageID
5 | The Package ID to install.
6 | .PARAMETER Version
7 | The version of the package to install. If unspecified, the latest stable release is installed.
8 | .PARAMETER Source
9 | The package source feed to find the package to install from.
10 | .PARAMETER PackagesDir
11 | The directory to install the package to. By default, it uses the Packages folder at the root of the repo.
12 | .PARAMETER ConfigFile
13 | The nuget.config file to use. By default, it uses :/nuget.config.
14 | .OUTPUTS
15 | System.String. The path to the installed package.
16 | #>
17 | [CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact='Low')]
18 | Param(
19 | [Parameter(Position=1,Mandatory=$true)]
20 | [string]$PackageId,
21 | [Parameter()]
22 | [string]$Version,
23 | [Parameter()]
24 | [string]$Source,
25 | [Parameter()]
26 | [switch]$Prerelease,
27 | [Parameter()]
28 | [string]$PackagesDir="$PSScriptRoot\..\packages",
29 | [Parameter()]
30 | [string]$ConfigFile="$PSScriptRoot\..\nuget.config",
31 | [Parameter()]
32 | [ValidateSet('Quiet','Normal','Detailed')]
33 | [string]$Verbosity='normal'
34 | )
35 |
36 | $nugetPath = & "$PSScriptRoot\Get-NuGetTool.ps1"
37 |
38 | try {
39 | Write-Verbose "Installing $PackageId..."
40 | $nugetArgs = "Install",$PackageId,"-OutputDirectory",$PackagesDir,'-ConfigFile',$ConfigFile
41 | if ($Version) { $nugetArgs += "-Version",$Version }
42 | if ($Source) { $nugetArgs += "-FallbackSource",$Source }
43 | if ($Prerelease) { $nugetArgs += "-Prerelease" }
44 | $nugetArgs += '-Verbosity',$Verbosity
45 |
46 | if ($PSCmdlet.ShouldProcess($PackageId, 'nuget install')) {
47 | $p = Start-Process $nugetPath $nugetArgs -NoNewWindow -Wait -PassThru
48 | if ($p.ExitCode -ne 0) { throw }
49 | }
50 |
51 | # Provide the path to the installed package directory to our caller.
52 | Write-Output (Get-ChildItem "$PackagesDir\$PackageId.*")[0].FullName
53 | } finally {
54 | Pop-Location
55 | }
56 |
--------------------------------------------------------------------------------
/signing/Set-EnvVars.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Set environment variables in the environment.
4 | Azure Pipeline and CMD environments are considered.
5 | .PARAMETER Variables
6 | A hashtable of variables to be set.
7 | .PARAMETER PrependPath
8 | A set of paths to prepend to the PATH environment variable.
9 | .OUTPUTS
10 | A boolean indicating whether the environment variables can be expected to propagate to the caller's environment.
11 | .DESCRIPTION
12 | The CmdEnvScriptPath environment variable may be optionally set to a path to a cmd shell script to be created (or appended to if it already exists) that will set the environment variables in cmd.exe that are set within the PowerShell environment.
13 | This is used by init.cmd in order to reapply any new environment variables to the parent cmd.exe process that were set in the powershell child process.
14 | #>
15 | [CmdletBinding(SupportsShouldProcess=$true)]
16 | Param(
17 | [Parameter(Mandatory=$true, Position=1)]
18 | $Variables,
19 | [string[]]$PrependPath
20 | )
21 |
22 | if ($Variables.Count -eq 0) {
23 | return $true
24 | }
25 |
26 | $cmdInstructions = !$env:TF_BUILD -and !$env:GITHUB_ACTIONS -and !$env:CmdEnvScriptPath -and ($env:PS1UnderCmd -eq '1')
27 | if ($cmdInstructions) {
28 | Write-Warning "Environment variables have been set that will be lost because you're running under cmd.exe"
29 | Write-Host "Environment variables that must be set manually:" -ForegroundColor Blue
30 | } else {
31 | Write-Host "Environment variables set:" -ForegroundColor Blue
32 | Write-Host ($Variables | Out-String)
33 | if ($PrependPath) {
34 | Write-Host "Paths prepended to PATH: $PrependPath"
35 | }
36 | }
37 |
38 | if ($env:TF_BUILD) {
39 | Write-Host "Azure Pipelines detected. Logging commands will be used to propagate environment variables and prepend path."
40 | }
41 |
42 | if ($env:GITHUB_ACTIONS) {
43 | Write-Host "GitHub Actions detected. Logging commands will be used to propagate environment variables and prepend path."
44 | }
45 |
46 | $CmdEnvScript = ''
47 | $Variables.GetEnumerator() |% {
48 | Set-Item -Path env:$($_.Key) -Value $_.Value
49 |
50 | # If we're running in a cloud CI, set these environment variables so they propagate.
51 | if ($env:TF_BUILD) {
52 | Write-Host "##vso[task.setvariable variable=$($_.Key);]$($_.Value)"
53 | }
54 | if ($env:GITHUB_ACTIONS) {
55 | Add-Content -Path $env:GITHUB_ENV -Value "$($_.Key)=$($_.Value)"
56 | }
57 |
58 | if ($cmdInstructions) {
59 | Write-Host "SET $($_.Key)=$($_.Value)"
60 | }
61 |
62 | $CmdEnvScript += "SET $($_.Key)=$($_.Value)`r`n"
63 | }
64 |
65 | $pathDelimiter = ';'
66 | if ($IsMacOS -or $IsLinux) {
67 | $pathDelimiter = ':'
68 | }
69 |
70 | if ($PrependPath) {
71 | $PrependPath |% {
72 | $newPathValue = "$_$pathDelimiter$env:PATH"
73 | Set-Item -Path env:PATH -Value $newPathValue
74 | if ($cmdInstructions) {
75 | Write-Host "SET PATH=$newPathValue"
76 | }
77 |
78 | if ($env:TF_BUILD) {
79 | Write-Host "##vso[task.prependpath]$_"
80 | }
81 | if ($env:GITHUB_ACTIONS) {
82 | Add-Content -Path $env:GITHUB_PATH -Value $_
83 | }
84 |
85 | $CmdEnvScript += "SET PATH=$_$pathDelimiter%PATH%"
86 | }
87 | }
88 |
89 | if ($env:CmdEnvScriptPath) {
90 | if (Test-Path $env:CmdEnvScriptPath) {
91 | $CmdEnvScript = (Get-Content -Path $env:CmdEnvScriptPath) + $CmdEnvScript
92 | }
93 |
94 | Set-Content -Path $env:CmdEnvScriptPath -Value $CmdEnvScript
95 | }
96 |
97 | return !$cmdInstructions
98 |
--------------------------------------------------------------------------------
/test.cmd:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 | PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0test.ps1' default-build %*; exit $LASTEXITCODE"
--------------------------------------------------------------------------------
/test.ps1:
--------------------------------------------------------------------------------
1 | $result = 0
2 | $errorColor = "Red"
3 | $successColor = "Green"
4 |
5 | if ($args[1] -eq '--eslint') {
6 | npm run lint
7 | if ($LASTEXITCODE -ne 0)
8 | {
9 | Write-Host "`nESLint Failed.`n" -ForegroundColor $errorColor
10 | $result = 1
11 | }
12 | else
13 | {
14 | Write-Host "`nESLint Succeeded.`n" -ForegroundColor $successColor
15 | }
16 | }
17 |
18 | if ($args[1] -ne 'sdk' -and $args[1] -ne 'rnt') {
19 | pushd vscode-dotnet-runtime-library
20 | if (Test-Path node_modules) { rm -r -force node_modules }
21 | npm ci --silent
22 | npm run test
23 | if ($LASTEXITCODE -ne 0)
24 | {
25 | Write-Host "`nAcquisition Library Tests Failed.`n" -ForegroundColor $errorColor
26 | $result = 1
27 | }
28 | else
29 | {
30 | Write-Host "`nAcquisition Library Tests Succeeded.`n" -ForegroundColor $successColor
31 | }
32 | popd
33 | }
34 |
35 | if ($args[1] -ne 'sdk' -and $args[1] -ne 'lib') {
36 | pushd vscode-dotnet-runtime-extension
37 | if (Test-Path node_modules) { rm -r -force node_modules }
38 | npm ci --silent
39 | npm run test
40 | if ($LASTEXITCODE -ne 0)
41 | {
42 | Write-Host "`n.NET Runtime Acquisition Extension Tests Failed.`n" -ForegroundColor $errorColor
43 | $result = 1
44 | }
45 | else
46 | {
47 | Write-Host "`n.NET Runtime Acquisition Extension Tests Succeeded.`n" -ForegroundColor $successColor
48 | }
49 | popd
50 | }
51 |
52 | if ($args[1] -ne 'lib' -and $args[1] -ne 'rnt') {
53 | pushd vscode-dotnet-sdk-extension
54 | if (Test-Path node_modules) { rm -r -force node_modules }
55 | npm ci --silent
56 | npm run test
57 | if ($LASTEXITCODE -ne 0)
58 | {
59 | Write-Host "`n.NET SDK Acquisition Extension Tests Failed.`n" -ForegroundColor $errorColor
60 | $result = 1
61 | }
62 | else
63 | {
64 | Write-Host "`n.NET SDK Acquisition Extension Tests Succeeded.`n" -ForegroundColor $successColor
65 | }
66 | popd
67 | }
68 |
69 | if ($result -ne 0)
70 | {
71 | Write-Host "`n`nTests Failed.`n" -ForegroundColor $errorColor
72 | exit $result
73 | }
74 | else
75 | {
76 | Write-Host "`n`nAll Tests Succeeded.`n" -ForegroundColor $successColor
77 | exit $result
78 | }
--------------------------------------------------------------------------------
/test.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | RESULT=0
3 | RED=`tput setaf 1`
4 | GREEN=`tput setaf 2`
5 | NC=`tput sgr0`
6 |
7 | if [ "$1" = "--eslint" ];
8 | then
9 | npm run lint
10 | if [ $? -ne 0 ];
11 | then
12 | echo ""
13 | echo "${RED}ESLint Failed.${NC}"
14 | echo ""
15 | RESULT=1
16 | else
17 | echo ""
18 | echo "${GREEN}ESLint Succeeded.${NC}"
19 | echo ""
20 | fi
21 | fi
22 |
23 | echo ""
24 | echo "----------- Testing vscode-dotnet-runtime-library -----------"
25 | echo ""
26 | pushd vscode-dotnet-runtime-library
27 | rm -rf node_modules
28 | npm ci
29 | npm run test
30 |
31 | if [ $? -ne 0 ];
32 | then
33 | echo ""
34 | echo "${RED}Acquisition Library Tests Failed.${NC}"
35 | echo ""
36 | RESULT=1
37 | else
38 | echo ""
39 | echo "${GREEN}Acquisition Library Tests Succeeded.${NC}"
40 | echo ""
41 | fi
42 | popd
43 |
44 | echo ""
45 | echo "----------- Testing vscode-dotnet-runtime-extension -----------"
46 | echo ""
47 | pushd vscode-dotnet-runtime-extension
48 | rm -rf node_modules
49 | npm ci
50 | npm run test
51 |
52 | if [ $? -ne 0 ];
53 | then
54 | echo ""
55 | echo "${RED}.NET Runtime Acquisition Extension Tests Failed.${NC}"
56 | echo ""
57 | RESULT=1
58 | else
59 | echo ""
60 | echo "${GREEN}.NET Runtime Acquisition Extension Tests Succeeded.${NC}"
61 | echo ""
62 | fi
63 | popd
64 |
65 | echo ""
66 | echo "----------- Testing vscode-dotnet-sdk-extension -----------"
67 | echo ""
68 | pushd vscode-dotnet-sdk-extension
69 | rm -rf node_modules
70 | npm ci
71 | npm run test
72 |
73 | if [ $? -ne 0 ];
74 | then
75 | echo ""
76 | echo "${RED}.NET SDK Acquisition Extension Tests Failed.${NC}"
77 | echo ""
78 | RESULT=1
79 | else
80 | echo ""
81 | echo "${GREEN}.NET SDK Acquisition Extension Tests Succeeded.${NC}"
82 | echo ""
83 | fi
84 | popd
85 |
86 | if [ $RESULT -ne 0 ];
87 | then
88 | echo ""
89 | echo ""
90 | echo "${RED}Tests Failed.${NC}"
91 | echo ""
92 | exit $RESULT
93 | else
94 | echo ""
95 | echo ""
96 | echo "${GREEN}All Tests Succeeded.${NC}"
97 | echo ""
98 | exit $RESULT
99 | fi
--------------------------------------------------------------------------------
/tsconfig.eslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "outDir": "dist",
6 | "lib": [
7 | "es6"
8 | ],
9 | "skipLibCheck": true,
10 | "sourceMap": true,
11 | "declaration": true,
12 | "rootDir": "src",
13 | "strict": true /* enable all strict type-checking options */
14 | },
15 | "exclude": [
16 | "**/node_modules/**",
17 | "**/.vscode-test/**",
18 | "**/dist/**",
19 | ]
20 | }
21 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-extension/.editorconfig:
--------------------------------------------------------------------------------
1 | # Editor config
2 | # http://EditorConfig.org
3 |
4 | root = true
5 |
6 | # Default rules applied to all file types
7 | [*]
8 | end_of_line = crlf
9 | charset = utf-8
10 | trim_trailing_whitespace = true
11 | insert_final_newline = true
12 | indent_style = space
13 | indent_size = 4
14 |
15 | # JavaScript-specific settings
16 | [*.{js,ts}]
17 | quote_type = single
18 | continuation_indent_size = 2
19 | curly_bracket_next_line = true
20 | indent_brace_style = BSD
21 | spaces_around_operators = true
22 | spaces_around_brackets = none
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-extension/.npmrc:
--------------------------------------------------------------------------------
1 | registry=https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-extension/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | // A launch configuration that compiles the extension and then opens it inside a new window
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | {
6 | "version": "0.2.0",
7 | "configurations": [
8 | {
9 | "name": "Run .NET Runtime Acquisition Extension",
10 | "type": "extensionHost",
11 | "request": "launch",
12 | "runtimeExecutable": "${execPath}",
13 | "args": [
14 | "--extensionDevelopmentPath=${workspaceFolder}"
15 | ],
16 | "outFiles": [
17 | "${workspaceFolder}/dist/**/*.js"
18 | ],
19 | "preLaunchTask": "compile-all"
20 | },
21 | {
22 | "name": ".NET Runtime Extension Functional Tests",
23 | "type": "extensionHost",
24 | "request": "launch",
25 | "runtimeExecutable": "${execPath}",
26 | "args": [
27 | "--disable-extensions",
28 | "--extensionDevelopmentPath=${workspaceFolder}",
29 | "--extensionTestsPath=${workspaceFolder}/dist/test/functional"
30 | ],
31 | "outFiles": [
32 | "${workspaceFolder}/dist/test/**/*.js"
33 | ],
34 | "internalConsoleOptions": "openOnSessionStart",
35 | "preLaunchTask": "compile-all"
36 | },
37 | {
38 | "type": "node",
39 | "request": "launch",
40 | "name": "Acquisition Library Unit Tests",
41 | "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
42 | "args": [
43 | "-u",
44 | "tdd",
45 | "--no-timeout",
46 | "--colors",
47 | "${workspaceFolder}/../vscode-dotnet-runtime-library/dist/test/unit/**.test.js"
48 | ],
49 | "internalConsoleOptions": "openOnSessionStart",
50 | "preLaunchTask": "compile-all"
51 | }
52 | ]
53 | }
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-extension/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.exclude": {
4 | "out": false // set this to true to hide the "out" folder with the compiled JS files
5 | },
6 | "search.exclude": {
7 | "out": true // set this to false to include "out" folder in search results
8 | },
9 | // Turn off tsc task auto detection since we have the necessary tasks as npm scripts
10 | "typescript.tsc.autoDetect": "off",
11 | // Formatting for every file
12 | "editor.formatOnSave": true,
13 | "javascript.format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces": false,
14 | "javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
15 | "javascript.format.placeOpenBraceOnNewLineForFunctions": true,
16 | "javascript.format.placeOpenBraceOnNewLineForControlBlocks": true,
17 | "typescript.format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces": false,
18 | "typescript.format.placeOpenBraceOnNewLineForControlBlocks": true,
19 | "typescript.format.placeOpenBraceOnNewLineForFunctions": true,
20 | "dotnetAcquisitionExtension.installTimeoutValue": 300,
21 | "typescript.inlayHints.enumMemberValues.enabled": true,
22 | "typescript.inlayHints.functionLikeReturnTypes.enabled": true,
23 | "typescript.inlayHints.parameterNames.enabled": "all",
24 | "typescript.referencesCodeLens.enabled": true,
25 | "typescript.referencesCodeLens.showOnAllFunctions": true,
26 | "typescript.implementationsCodeLens.enabled": true,
27 | "typescript.implementationsCodeLens.showOnInterfaceMethods": true,
28 | "typescript.preferences.quoteStyle": "single",
29 | "typescript.preferGoToSourceDefinition": true,
30 | "editor.codeActionsOnSave": {
31 | "source.organizeImports": "explicit"
32 | }
33 | }
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-extension/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | // See https://go.microsoft.com/fwlink/?LinkId=733558
2 | // for the documentation about the tasks.json format
3 | {
4 | "version": "2.0.0",
5 | "tasks": [
6 | {
7 | "label": "compile-all",
8 | "type": "npm",
9 | "script": "compile-all",
10 | "presentation": {
11 | "reveal": "never"
12 | },
13 | "group": {
14 | "kind": "build",
15 | "isDefault": true
16 | }
17 | }
18 | ]
19 | }
20 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-extension/images/dotnetIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet/vscode-dotnet-runtime/9d40cb68b5a08530b000b70b0ff02ec2067d851a/vscode-dotnet-runtime-extension/images/dotnetIcon.png
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-extension/src/DotnetCoreAcquisitionId.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | export const dotnetCoreAcquisitionExtensionId = 'ms-dotnettools.vscode-dotnet-runtime';
7 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-extension/src/test/functional/index.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 | import * as glob from 'glob';
6 | import * as Mocha from 'mocha';
7 | import * as path from 'path';
8 |
9 | export function run(): Promise {
10 | // Create the mocha test
11 | const mocha = new Mocha({
12 | ui: 'tdd',
13 | color: true,
14 | });
15 |
16 | const testsRoot = path.resolve(__dirname, '..');
17 |
18 | return new Promise((c, e) => {
19 | glob('**/functional/**.test.js', { cwd: testsRoot }, (err, files) => {
20 | if (err) {
21 | return e(err);
22 | }
23 |
24 | // Add files to the test suite
25 | files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
26 |
27 | try {
28 | // Run the mocha test
29 | mocha.run(failures => {
30 | if (failures > 0) {
31 | e(new Error(`${failures} tests failed.`));
32 | } else {
33 | c();
34 | }
35 | });
36 | } catch (err) {
37 | e(err);
38 | }
39 | });
40 | });
41 | }
42 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-extension/src/test/functional/runTest.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | import * as os from 'os';
7 | import * as path from 'path';
8 |
9 | import { runTests } from '@vscode/test-electron';
10 |
11 | async function main()
12 | {
13 | try
14 | {
15 | // The folder containing the Extension Manifest package.json
16 | // Passed to `--extensionDevelopmentPath`
17 | const extensionDevelopmentPath = path.resolve(__dirname, '../../../');
18 |
19 | // The path to the extension test runner script
20 | // Passed to --extensionTestsPath
21 | const extensionTestsPath = path.resolve(__dirname, './index');
22 |
23 | let platformValue = '';
24 | switch (os.platform())
25 | {
26 | case 'win32':
27 | platformValue = 'win32-x64-archive';
28 | break;
29 | case 'darwin':
30 | platformValue = 'darwin';
31 | break;
32 | case 'linux':
33 | platformValue = 'linux-x64';
34 | break;
35 | }
36 |
37 | // Download VS Code, unzip it and run the integration test
38 | await runTests(
39 | {
40 | ...(platformValue !== '' && { platform: platformValue }),
41 | extensionDevelopmentPath,
42 | extensionTestsPath,
43 | launchArgs: [
44 | // This disables all extensions except the one being testing
45 | '--disable-extensions',
46 | ],
47 | extensionTestsEnv: { DOTNET_INSTALL_TOOL_UNDER_TEST: 'true' }
48 | }
49 | );
50 | }
51 | catch (err)
52 | {
53 | console.error('Failed to run tests');
54 | process.exit(1);
55 | }
56 | }
57 |
58 | main();
59 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-extension/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "outDir": "dist",
6 | "lib": [
7 | "es6"
8 | ],
9 | "sourceMap": true,
10 | "rootDir": "src",
11 | "declaration": true,
12 | "strict": true /* enable all strict type-checking options */
13 | },
14 | "exclude": [
15 | "node_modules",
16 | ".vscode-test",
17 | "dist"
18 | ]
19 | }
20 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-extension/webpack.config.js:
--------------------------------------------------------------------------------
1 | //@ts-check
2 |
3 | 'use strict';
4 |
5 | const path = require('path');
6 | const CopyPlugin = require('copy-webpack-plugin');
7 | const { exec } = require('node:child_process');
8 | const PermissionsOutputPlugin = require('webpack-permissions-plugin');
9 |
10 | /**@type {import('webpack').Configuration}*/
11 | const config = {
12 | target: 'node', // vscode extensions run in a Node.js-context 📖 -> https://webpack.js.org/configuration/node/
13 |
14 | entry: './/src/extension.ts', // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/
15 | output: {
16 | // the bundle is stored in the 'dist' folder (check package.json), 📖 -> https://webpack.js.org/configuration/output/
17 | path: path.resolve(__dirname, 'dist'),
18 | filename: 'extension.js',
19 | libraryTarget: 'commonjs2',
20 | devtoolModuleFilenameTemplate: '../[resource-path]'
21 | },
22 | node: {
23 | __dirname: false,
24 | __filename: false,
25 | },
26 | devtool: 'source-map',
27 | externals: {
28 | vscode: 'commonjs vscode', // the vscode-module is created on-the-fly and must be excluded. Add other modules that cannot be webpack'ed, 📖 -> https://webpack.js.org/configuration/externals/
29 | 'applicationinsights-native-metrics': 'commonjs applicationinsights-native-metrics' // ignored because we don't ship native module
30 | },
31 | resolve: {
32 | // support reading TypeScript and JavaScript files, 📖 -> https://github.com/TypeStrong/ts-loader
33 | extensions: ['.ts', '.js']
34 | },
35 | module: {
36 | rules: [
37 | {
38 | test: /\.ts$/,
39 | exclude: /node_modules/,
40 | use: [
41 | {
42 | loader: 'ts-loader'
43 | }
44 | ]
45 | }
46 | ]
47 | },
48 | plugins: [
49 | new CopyPlugin({ patterns: [
50 | { from: path.resolve(__dirname, '../vscode-dotnet-runtime-library/install scripts'), to: path.resolve(__dirname, 'dist', 'install scripts') },
51 | { from: path.resolve(__dirname, '../vscode-dotnet-runtime-library/distro-data'), to: path.resolve(__dirname, 'dist', 'distro-data') },
52 | { from: path.resolve(__dirname, '../images'), to: path.resolve(__dirname, 'images') },
53 | { from: path.resolve(__dirname, '../LICENSE.txt'), to: path.resolve(__dirname, 'LICENSE.txt') }
54 | ]}),
55 | new PermissionsOutputPlugin({
56 | buildFolders: [
57 | ],
58 | buildFiles: [
59 | {
60 | path: path.resolve(__dirname, 'dist', 'distro-data', 'distro-support.json'),
61 | fileMode: '544'
62 | },
63 | {
64 | path: path.resolve(__dirname, 'dist', 'install scripts', 'interprocess-communicator.sh'),
65 | fileMode: '500'
66 | }
67 | ]
68 | })
69 | ]
70 | };
71 | module.exports = config;
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/.npmrc:
--------------------------------------------------------------------------------
1 | registry=https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/
2 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.exclude": {
4 | "out": false // set this to true to hide the "out" folder with the compiled JS files
5 | },
6 | "search.exclude": {
7 | "out": true // set this to false to include "out" folder in search results
8 | },
9 | // Turn off tsc task auto detection since we have the necessary tasks as npm scripts
10 | "typescript.tsc.autoDetect": "off",
11 | "cSpell.words": [
12 | "aspnet",
13 | "aspnetcore",
14 | "hasher",
15 | "HKCU",
16 | "HKEY",
17 | "norestart",
18 | "OPTOUT",
19 | "pkexec",
20 | "REGHEXVALUE",
21 | "REGTYPE",
22 | "setx",
23 | "vscd"
24 | ],
25 | // Formatting on save
26 | "editor.formatOnSave": true,
27 | "javascript.format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces": false,
28 | "javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
29 | "javascript.format.placeOpenBraceOnNewLineForFunctions": true,
30 | "javascript.format.placeOpenBraceOnNewLineForControlBlocks": true,
31 | "typescript.format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces": false,
32 | "typescript.format.placeOpenBraceOnNewLineForControlBlocks": true,
33 | "typescript.format.placeOpenBraceOnNewLineForFunctions": true,
34 | "dotnetAcquisitionExtension.installTimeoutValue": 300,
35 | "typescript.inlayHints.enumMemberValues.enabled": true,
36 | "typescript.inlayHints.functionLikeReturnTypes.enabled": true,
37 | "typescript.inlayHints.parameterNames.enabled": "all",
38 | "typescript.referencesCodeLens.enabled": true,
39 | "typescript.referencesCodeLens.showOnAllFunctions": true,
40 | "typescript.implementationsCodeLens.enabled": true,
41 | "typescript.implementationsCodeLens.showOnInterfaceMethods": true,
42 | "typescript.preferences.quoteStyle": "single",
43 | "typescript.preferGoToSourceDefinition": true,
44 | "editor.codeActionsOnSave": {
45 | "source.organizeImports": "explicit"
46 | }
47 | }
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/install scripts/determine-linux-distro.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Copyright © Microsoft Corporation
4 | # All rights reserved.
5 | #
6 | # Licensed under the MIT License. See LICENSE-CODE in the project root for details.
7 | #
8 | # Exit codes:
9 | # 0 - Success
10 | # 4 - Distribution not supported by script
11 | #
12 |
13 | set H+
14 |
15 | #openSUSE - Has to be first since apt-get is available but package names different
16 | if type zypper > /dev/null 2>&1; then
17 | echo "SUSE"
18 | exit 0
19 |
20 | # Debian / Ubuntu
21 | elif type apt-get > /dev/null 2>&1; then
22 | echo "Debian"
23 | exit 0
24 |
25 | #RHL/Fedora/CentOS
26 | elif type yum > /dev/null 2>&1; then
27 | echo "RedHat"
28 | exit 0
29 |
30 | #ArchLinux
31 | elif type pacman > /dev/null 2>&1; then
32 | echo "ArchLinux"
33 | exit 0
34 |
35 | #Solus
36 | elif type eopkg > /dev/null 2>&1; then
37 | echo "Solus"
38 | exit 0
39 |
40 | #Alpine Linux
41 | elif type apk > /dev/null 2>&1; then
42 | echo "Alpine"
43 | exit 0
44 |
45 | # Distro not supported
46 | else
47 | echo "UNKNOWN"
48 | exit 4
49 | fi
50 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/install scripts/interprocess-communicator.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | EXECFOLDER=$1 # First argument is the working folder as this is launched with cwd of /root
3 | TIMEOUT_SEC=$2
4 | OKSIGNALFILE="$EXECFOLDER/ok.txt"
5 | COMMANDTORUNFILE="$EXECFOLDER/command.txt"
6 | EXITFILE="$EXECFOLDER/exit.txt"
7 | #OUTPUTFILE="/home/test_output_.txt"
8 | end=$((SECONDS+3600))
9 |
10 | function finish {
11 | rm -f "$COMMANDTORUNFILE"
12 | rm -f "$OKSIGNALFILE"
13 | }
14 | trap finish EXIT
15 |
16 | export DEBIAN_FRONTEND=noninteractive
17 |
18 | while true
19 | do
20 | stop=false
21 | while [ $SECONDS -lt $end ];
22 | do
23 | if test -f "$COMMANDTORUNFILE"; then
24 | # echo "COMMAND FILE FOUND" >> "$OUTPUTFILE" # Leave this here as an example of debugging
25 | COMMAND="$(cat "$COMMANDTORUNFILE" | awk '{$1=$1;print}')"
26 | for validCmd in "${@:3}"
27 | do
28 | if [ "$COMMAND" == "$validCmd" ]; then
29 | # Eventually we should split the cmd file to be line by line instead of space separated,
30 | # but it works for now because the commands are running under sudo
31 | IFS=' ' read -ra COMMANDARGS <<< "$COMMAND"
32 | fi
33 | done
34 | if [ -z "$COMMANDARGS" ]; then
35 | rm "$COMMANDTORUNFILE"
36 | exit 111777 # Special exit code - arbitrarily picked for when the command is not expected
37 | fi
38 | sudo "${COMMANDARGS[@]}" 2> "$EXECFOLDER/stderr.txt" 1> "$EXECFOLDER/stdout.txt"
39 | STATUSCODE=$?
40 | echo $STATUSCODE > "$EXECFOLDER/status.txt"
41 | rm "$COMMANDTORUNFILE"
42 | touch "$EXECFOLDER/output.txt"
43 | fi
44 | if test -f "$OKSIGNALFILE"; then
45 | rm "$OKSIGNALFILE"
46 | fi
47 | if test -f "$EXITFILE"; then
48 | rm "$EXITFILE"
49 | exit 0
50 | fi
51 | sleep 5
52 | done
53 | done
54 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vscode-dotnet-runtime-library",
3 | "description": "A library to acquire .NET Core runtimes.",
4 | "version": "1.0.0",
5 | "repository": {
6 | "type": "git",
7 | "url": "https://github.com/dotnet/vscode-dotnet-runtime.git"
8 | },
9 | "license": "MIT",
10 | "engines": {
11 | "vscode": "^1.99.0"
12 | },
13 | "main": "./dist/index.js",
14 | "types": "./dist/index.d.ts",
15 | "scripts": {
16 | "vscode:prepublish": "npm run compile && dotnet build ../msbuild/signJs --property jsOutputPath=..\\..\\vscode-dotnet-runtime-library\\dist -bl -v:normal",
17 | "compile": "npm run clean && tsc -p ./ && npm run mockPack",
18 | "mockPack": "run-script-os",
19 | "mockPack:darwin:linux": "cd .. && sh ./mock-webpack.sh && cd vscode-dotnet-runtime-library",
20 | "mockPack:win32": "pushd .. && @powershell -NoProfile -ExecutionPolicy Unrestricted -Command ./mock-webpack.ps1 && popd",
21 | "watch": "npm run clean && tsc -watch -p ./",
22 | "test": "npm run compile --silent && npm run unit-test",
23 | "unit-test": "mocha -u tdd -- dist/test/unit/**.test.js",
24 | "clean": "rimraf dist"
25 | },
26 | "devDependencies": {
27 | "@types/chai": "4.2.22",
28 | "@types/lodash": "^4.17.13",
29 | "@types/proper-lockfile": "^4.1.2",
30 | "glob": "^7.2.0"
31 | },
32 | "dependencies": {
33 | "@types/chai-as-promised": "^7.1.4",
34 | "@types/mocha": "^9.0.0",
35 | "@types/node": "^20.0.0",
36 | "@types/rimraf": "3.0.2",
37 | "@types/semver": "^7.3.9",
38 | "@types/shelljs": "^0.8.9",
39 | "@types/vscode": "1.74.0",
40 | "@vscode/extension-telemetry": "^0.9.7",
41 | "@vscode/sudo-prompt": "^9.3.1",
42 | "@vscode/test-electron": "^2.4.1",
43 | "axios": "^1.7.4",
44 | "axios-cache-interceptor": "^1.5.3",
45 | "axios-retry": "^3.4.0",
46 | "chai": "4.3.4",
47 | "chai-as-promised": "^7.1.1",
48 | "eol": "^0.9.1",
49 | "get-proxy-settings": "^0.1.13",
50 | "https-proxy-agent": "^7.0.4",
51 | "lodash": "^4.17.21",
52 | "mocha": "^9.1.3",
53 | "node-cache": "^5.1.2",
54 | "open": "^8.4.0",
55 | "rimraf": "3.0.2",
56 | "run-script-os": "^1.1.6",
57 | "semver": "^7.6.2",
58 | "shelljs": "^0.8.5",
59 | "typescript": "^5.5.4"
60 | },
61 | "optionalDependencies": {
62 | "fsevents": "^2.3.3"
63 | }
64 | }
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Acquisition/ASPNetRuntimeInstallationDirectoryProvider.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | import * as path from 'path';
7 | import { IInstallationDirectoryProvider } from './IInstallationDirectoryProvider';
8 |
9 | export class ASPNetRuntimeInstallationDirectoryProvider extends IInstallationDirectoryProvider {
10 | public getInstallDir(installId: string): string
11 | {
12 | const dotnetInstallDir = path.join(this.getStoragePath(), installId);
13 | return dotnetInstallDir;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Acquisition/CacheTimeConstants.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 | export const GLOBAL_LOCK_PING_DURATION_MS = 50;
6 | export const LOCAL_LOCK_PING_DURATION_MS = 10;
7 |
8 | export const SUDO_LOCK_PING_DURATION_MS = 20;
9 |
10 | export const DOTNET_INFORMATION_CACHE_DURATION_MS = 9000;
11 |
12 | export const SYS_CMD_SEARCH_CACHE_DURATION_MS = 30000;
13 |
14 | export const READ_SYMLINK_CACHE_DURATION_MS = 4000;
15 |
16 | export const SYSTEM_INFORMATION_CACHE_DURATION_MS = 1200000;
17 |
18 | export const WEB_CACHE_DURATION_MS = 300000;
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Acquisition/DebianDistroSDKProvider.ts:
--------------------------------------------------------------------------------
1 | /* --------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | * Licensed under the MIT License. See License.txt in the project root for license information.
5 | * ------------------------------------------------------------------------------------------ */
6 | import { ICommandExecutor } from '../Utils/ICommandExecutor';
7 | import { IUtilityContext } from '../Utils/IUtilityContext';
8 | import { DotnetInstallMode } from './DotnetInstallMode';
9 | import { GenericDistroSDKProvider } from './GenericDistroSDKProvider';
10 | import { IAcquisitionWorkerContext } from './IAcquisitionWorkerContext';
11 | import { DistroVersionPair } from './LinuxVersionResolver';
12 |
13 | export class DebianDistroSDKProvider extends GenericDistroSDKProvider
14 | {
15 | constructor(distroVersion: DistroVersionPair, context: IAcquisitionWorkerContext, utilContext: IUtilityContext, executor: ICommandExecutor | null = null)
16 | {
17 | super(distroVersion, context, utilContext, executor);
18 | }
19 | public override async dotnetPackageExistsOnSystem(fullySpecifiedDotnetVersion: string, installType: DotnetInstallMode): Promise
20 | {
21 | await this.injectPMCFeed(fullySpecifiedDotnetVersion, installType);
22 | return super.dotnetPackageExistsOnSystem(fullySpecifiedDotnetVersion, installType);
23 | }
24 | }
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Acquisition/DirectoryProviderFactory.ts:
--------------------------------------------------------------------------------
1 | /* --------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | * Licensed under the MIT License. See License.txt in the project root for license information.
5 | * ------------------------------------------------------------------------------------------ */
6 |
7 | import { ASPNetRuntimeInstallationDirectoryProvider } from './ASPNetRuntimeInstallationDirectoryProvider';
8 | import { DotnetInstallMode } from './DotnetInstallMode';
9 | import { IInstallationDirectoryProvider } from './IInstallationDirectoryProvider';
10 | import { RuntimeInstallationDirectoryProvider } from './RuntimeInstallationDirectoryProvider';
11 | import { SdkInstallationDirectoryProvider } from './SdkInstallationDirectoryProvider';
12 |
13 |
14 | export function directoryProviderFactory(mode: DotnetInstallMode, storagePath: string) : IInstallationDirectoryProvider
15 | {
16 | return mode === 'runtime' ? new RuntimeInstallationDirectoryProvider(storagePath) :
17 | mode === 'sdk' ? new SdkInstallationDirectoryProvider(storagePath) :
18 | mode === 'aspnetcore' ? new ASPNetRuntimeInstallationDirectoryProvider(storagePath)
19 | : new RuntimeInstallationDirectoryProvider(storagePath); // default if no mode is provided - should never happen
20 | }
21 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Acquisition/DotnetInstallMode.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | export type DotnetInstallMode = 'sdk' | 'runtime' | 'aspnetcore';
7 |
8 | export const DOTNET_INSTALL_MODE_LIST = ['sdk', 'runtime', 'aspnetcore'];
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Acquisition/IAcquisitionInvoker.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 | import { IEventStream } from '../EventStream/EventStream';
6 | import { DotnetInstall } from './DotnetInstall';
7 | import { IInstallationValidator } from './IInstallationValidator';
8 | import { InstallationValidator } from './InstallationValidator';
9 |
10 | export abstract class IAcquisitionInvoker
11 | {
12 | public readonly installationValidator: IInstallationValidator;
13 | constructor(protected readonly eventStream: IEventStream)
14 | {
15 | this.installationValidator = new InstallationValidator(eventStream);
16 | }
17 |
18 | public abstract installDotnet(install: DotnetInstall): Promise;
19 | }
20 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Acquisition/IAcquisitionWorkerContext.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 | import { IDotnetAcquireContext } from '../IDotnetAcquireContext';
6 | import { IEventStream } from '../EventStream/EventStream';
7 | import { IExtensionState } from '../IExtensionState';
8 | import { IInstallationDirectoryProvider } from './IInstallationDirectoryProvider';
9 | import { IInstallationValidator } from './IInstallationValidator';
10 |
11 | export interface IAcquisitionWorkerContext
12 | {
13 | storagePath: string;
14 | extensionState: IExtensionState;
15 | eventStream: IEventStream;
16 | installationValidator: IInstallationValidator;
17 | timeoutSeconds: number;
18 | installDirectoryProvider: IInstallationDirectoryProvider;
19 | acquisitionContext : IDotnetAcquireContext;
20 | proxyUrl? : string | undefined;
21 | isExtensionTelemetryInitiallyEnabled : boolean;
22 | allowInvalidPathSetting : boolean;
23 | }
24 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Acquisition/IDotnetConditionValidator.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | import { IDotnetFindPathContext } from '../IDotnetFindPathContext';
7 |
8 | export interface IDotnetConditionValidator
9 | {
10 | dotnetMeetsRequirement(dotnetExecutablePath: string, requirement : IDotnetFindPathContext): Promise;
11 | }
12 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Acquisition/IDotnetCoreAcquisitionWorker.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | import { IEventStream } from '../EventStream/EventStream';
7 | import { IDotnetAcquireResult } from '../IDotnetAcquireResult';
8 | import { IExtensionState } from '../IExtensionState';
9 | import { GlobalInstallerResolver } from './GlobalInstallerResolver';
10 | import { IAcquisitionInvoker } from './IAcquisitionInvoker';
11 | import { IAcquisitionWorkerContext } from './IAcquisitionWorkerContext';
12 |
13 | export interface IDotnetCoreAcquisitionWorker
14 | {
15 | uninstallAll(eventStream: IEventStream, storagePath: string, extensionState: IExtensionState): Promise;
16 |
17 | acquireLocalRuntime(context: IAcquisitionWorkerContext, invoker: IAcquisitionInvoker): Promise;
18 |
19 | acquireLocalASPNET(context: IAcquisitionWorkerContext, invoker: IAcquisitionInvoker): Promise;
20 |
21 | acquireLocalSDK(context: IAcquisitionWorkerContext, invoker: IAcquisitionInvoker): Promise;
22 |
23 | acquireGlobalSDK(context: IAcquisitionWorkerContext, installerResolver: GlobalInstallerResolver): Promise;
24 | }
25 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Acquisition/IDotnetInstallationContext.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | import { DotnetInstallType } from '../IDotnetAcquireContext';
7 | import { DotnetInstallMode } from './DotnetInstallMode';
8 |
9 | export interface IDotnetInstallationContext {
10 | installDir: string;
11 | version: string;
12 | dotnetPath: string;
13 | timeoutSeconds: number;
14 | installMode : DotnetInstallMode;
15 | installType : DotnetInstallType;
16 | architecture: string;
17 | }
18 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Acquisition/IDotnetListInfo.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | import { DotnetInstallMode } from "./DotnetInstallMode";
7 |
8 | export interface IDotnetListInfo { mode: DotnetInstallMode, version: string, directory : string, architecture: string | null };
9 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Acquisition/IDotnetPathFinder.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | import { InstallRecordWithPath } from './InstallRecordWithPath';
7 |
8 | export interface IDotnetPathFinder
9 | {
10 | findDotnetRootPath(requestedArchitecture: string): Promise;
11 | findRawPathEnvironmentSetting(tryUseTrueShell: boolean, requestedArchitecture: string | null): Promise;
12 | findRealPathEnvironmentSetting(tryUseTrueShell: boolean, requestedArchitecture: string | null): Promise;
13 | findHostInstallPaths(requestedArchitecture: string): Promise;
14 | findExtensionManagedRuntimes(requestedArchitecture: string | null): Promise;
15 | }
16 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Acquisition/IGlobalInstaller.ts:
--------------------------------------------------------------------------------
1 | /* --------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | * Licensed under the MIT License. See License.txt in the project root for license information.
5 | * ------------------------------------------------------------------------------------------ */
6 |
7 | import path = require('path');
8 | import crypto = require('crypto')
9 | import { IAcquisitionWorkerContext } from './IAcquisitionWorkerContext';
10 | import { IUtilityContext } from '../Utils/IUtilityContext';
11 | import { DotnetInstall } from './DotnetInstall';
12 |
13 | export abstract class IGlobalInstaller {
14 |
15 | protected acquisitionContext : IAcquisitionWorkerContext;
16 | protected utilityContext : IUtilityContext;
17 |
18 | constructor(acquisitionContext : IAcquisitionWorkerContext, utilContext : IUtilityContext) {
19 | this.acquisitionContext = acquisitionContext;
20 | this.utilityContext = utilContext;
21 | }
22 |
23 | public abstract installSDK(install : DotnetInstall) : Promise
24 |
25 | public abstract uninstallSDK(install : DotnetInstall) : Promise
26 |
27 | public abstract getExpectedGlobalSDKPath(specificSDKVersionInstalled : string, installedArch : string, macPathShouldExist? : boolean) : Promise
28 |
29 | /**
30 | *
31 | * @returns The folder where global sdk installers will be downloaded onto the disk.
32 | */
33 | public static getDownloadedInstallFilesFolder(uniqueInstallerId : string) : string
34 | {
35 | return path.join(__dirname, 'installers', crypto.createHash('sha256').update(uniqueInstallerId).digest('hex'));
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Acquisition/IInstallScriptAcquisitionWorker.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | export interface IInstallScriptAcquisitionWorker {
7 | getDotnetInstallScriptPath(): Promise;
8 | }
9 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Acquisition/IInstallationDirectoryProvider.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 | import * as path from 'path';
6 |
7 | export abstract class IInstallationDirectoryProvider
8 | {
9 | constructor(protected storagePath: string) {}
10 |
11 | public abstract getInstallDir(installId: string): string;
12 |
13 | public getStoragePath(): string
14 | {
15 | const installFolderName = process.env._VSCODE_DOTNET_INSTALL_FOLDER || '.dotnet';
16 | return path.join(this.storagePath, installFolderName);
17 | }
18 | }
19 |
20 |
21 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Acquisition/IInstallationValidator.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | import { IEventStream } from '../EventStream/EventStream';
7 | import { DotnetInstall } from './DotnetInstall';
8 |
9 | export abstract class IInstallationValidator
10 | {
11 | constructor(protected readonly eventStream: IEventStream) {}
12 |
13 | public abstract validateDotnetInstall(install: DotnetInstall, dotnetPath: string, isDotnetFolder?: boolean, failOnErr?: boolean): void;
14 | }
15 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Acquisition/IJsonInstaller.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | import { IEventStream } from '../EventStream/EventStream';
7 | import { IVSCodeExtensionContext } from '../IVSCodeExtensionContext';
8 |
9 | export abstract class IJsonInstaller
10 | {
11 | constructor(protected readonly eventStream: IEventStream, protected readonly vscodeAccessor : IVSCodeExtensionContext) {}
12 |
13 | public abstract executeJSONRequests(): Promise;
14 | }
15 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Acquisition/IRegistryReader.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | import { IEventStream } from '../EventStream/EventStream';
7 | import { IVSCodeExtensionContext } from '../IVSCodeExtensionContext';
8 |
9 | export abstract class IRegistryReader
10 | {
11 | constructor() {}
12 |
13 | public abstract getGlobalSdkVersionsInstalledOnMachine() : Promise>;
14 | }
15 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Acquisition/IVersionResolver.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | import { DotnetInstallMode } from './DotnetInstallMode';
7 |
8 | export interface IVersionResolver
9 | {
10 | getFullVersion(version: string, mode : DotnetInstallMode): Promise;
11 | }
12 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Acquisition/InstallRecord.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | import { DotnetInstall, DotnetInstallWithKey } from './DotnetInstall';
7 |
8 | /**
9 | * @remarks
10 | * The string containing the extensionid of the extension which requested the install.
11 | * 'user' if the user installed it themselves.
12 | * null if we don't know because the install was done before we kept track of these things.
13 | * It can also be null if the install was done by an external source ...
14 | * including a different user on the machine through our extension. (they should manage it.)
15 | */
16 | export type InstallOwner = string | null;
17 |
18 | /**
19 | * @remarks
20 | * Records to save between extension loads to know who owns what installs and which ones exist.
21 | * Some of the types exist due to a need to support existing installs before this type existed.
22 | * All discovered old installs should be replaced with the new type.
23 | */
24 | export interface InstallRecord
25 | {
26 | dotnetInstall: DotnetInstall;
27 | installingExtensions: InstallOwner[];
28 | }
29 |
30 | /**
31 | * This is for when the installId was called installKey, which was changed to prevent telemetry filtering issues because of the word 'key' being
32 | * a bad word for vscode.
33 | */
34 | export interface InstallRecordWithKey
35 | {
36 | dotnetInstall: DotnetInstallWithKey;
37 | installingExtensions: InstallOwner[];
38 | }
39 |
40 |
41 | /**
42 | * @remarks
43 | * The record can be the type or it can be a 'legacy' record from old installs which is just a string with the install key.
44 | */
45 | export type InstallRecordOrStr = InstallRecord | string | InstallRecordWithKey;
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Acquisition/InstallRecordWithPath.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | import { InstallRecord } from './InstallRecord';
7 |
8 | /**
9 | * Represents a .NET installation record along with its filesystem path
10 | */
11 | export interface InstallRecordWithPath
12 | {
13 | installRecord: InstallRecord;
14 | path: string;
15 | }
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Acquisition/LinuxGlobalInstaller.ts:
--------------------------------------------------------------------------------
1 | /* --------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | * Licensed under the MIT License. See License.txt in the project root for license information.
5 | * ------------------------------------------------------------------------------------------ */
6 |
7 | import * as os from 'os';
8 | import * as path from 'path';
9 | import { IUtilityContext } from '../Utils/IUtilityContext';
10 | import { executeWithLock, getDotnetExecutable } from '../Utils/TypescriptUtilities';
11 | import { GLOBAL_LOCK_PING_DURATION_MS } from './CacheTimeConstants';
12 | import { GetDotnetInstallInfo } from './DotnetInstall';
13 | import { IAcquisitionWorkerContext } from './IAcquisitionWorkerContext';
14 | import { IGlobalInstaller } from './IGlobalInstaller';
15 | import { DotnetDistroSupportStatus, LinuxVersionResolver } from './LinuxVersionResolver';
16 | import { GLOBAL_INSTALL_STATE_MODIFIER_LOCK } from './StringConstants';
17 |
18 |
19 | export class LinuxGlobalInstaller extends IGlobalInstaller
20 | {
21 | private version: string;
22 | private linuxSDKResolver: LinuxVersionResolver;
23 |
24 | constructor(acquisitionContext: IAcquisitionWorkerContext, utilContext: IUtilityContext, fullySpecifiedDotnetVersion: string)
25 | {
26 | super(acquisitionContext, utilContext);
27 | this.linuxSDKResolver = new LinuxVersionResolver(acquisitionContext, utilContext);
28 | this.version = fullySpecifiedDotnetVersion;
29 | }
30 |
31 | public async installSDK(): Promise
32 | {
33 | await this.linuxSDKResolver.Initialize();
34 |
35 | return executeWithLock(this.acquisitionContext.eventStream, false, GLOBAL_INSTALL_STATE_MODIFIER_LOCK(this.acquisitionContext.installDirectoryProvider,
36 | GetDotnetInstallInfo(this.version, 'sdk', 'global', os.arch())), GLOBAL_LOCK_PING_DURATION_MS, this.acquisitionContext.timeoutSeconds * 1000,
37 | async () =>
38 | {
39 | return this.linuxSDKResolver.ValidateAndInstallSDK(this.version);
40 | },);
41 | }
42 |
43 | public async uninstallSDK(): Promise
44 | {
45 | await this.linuxSDKResolver.Initialize();
46 | return this.linuxSDKResolver.UninstallSDK(this.version);
47 | }
48 |
49 | public async getExpectedGlobalSDKPath(specificSDKVersionInstalled: string, installedArch: string, macPathShouldExist = true): Promise
50 | {
51 | await this.linuxSDKResolver.Initialize();
52 |
53 | const dotnetFolder = await (await this.linuxSDKResolver.distroCall()).getDotnetVersionSupportStatus(specificSDKVersionInstalled, 'sdk') === DotnetDistroSupportStatus.Distro ?
54 | (await this.linuxSDKResolver.distroCall()).getExpectedDotnetDistroFeedInstallationDirectory() :
55 | (await this.linuxSDKResolver.distroCall()).getExpectedDotnetMicrosoftFeedInstallationDirectory();
56 | return path.join(dotnetFolder, getDotnetExecutable());
57 | }
58 |
59 | public async getGlobalSdkVersionsInstalledOnMachine(): Promise
60 | {
61 | await this.linuxSDKResolver.Initialize();
62 |
63 | return (await this.linuxSDKResolver.distroCall()).getInstalledDotnetSDKVersions();
64 | }
65 |
66 | }
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Acquisition/LinuxPackageCollection.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | export type LinuxPackageCollection =
7 | {
8 | version : string,
9 | packages : string[]
10 | }
11 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Acquisition/RedHatDistroSDKProvider.ts:
--------------------------------------------------------------------------------
1 | /* --------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | * Licensed under the MIT License. See License.txt in the project root for license information.
5 | * ------------------------------------------------------------------------------------------ */
6 | import { ICommandExecutor } from '../Utils/ICommandExecutor';
7 | import { IUtilityContext } from '../Utils/IUtilityContext';
8 | import { GenericDistroSDKProvider } from './GenericDistroSDKProvider';
9 | import { IAcquisitionWorkerContext } from './IAcquisitionWorkerContext';
10 | import { DistroVersionPair } from './LinuxVersionResolver';
11 |
12 | export class RedHatDistroSDKProvider extends GenericDistroSDKProvider
13 | {
14 | constructor(distroVersion : DistroVersionPair, context : IAcquisitionWorkerContext, utilContext : IUtilityContext, executor : ICommandExecutor | null = null)
15 | {
16 | super(distroVersion, context, utilContext, executor);
17 | }
18 |
19 | protected myVersionDetails() : any
20 | {
21 | // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
22 | const distroVersions = this.distroJson[this.distroVersion.distro][this.distroVersionsKey];
23 | const targetVersion = Math.floor(parseFloat(this.distroVersion.version[0])).toFixed(1);
24 | // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
25 | const versionData = distroVersions.filter((x: { [x: string]: string; }) => x[this.versionKey] === String(targetVersion));
26 | return versionData;
27 | }
28 | }
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Acquisition/RuntimeInstallationDirectoryProvider.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | import * as path from 'path';
7 | import { IInstallationDirectoryProvider } from './IInstallationDirectoryProvider';
8 |
9 | export class RuntimeInstallationDirectoryProvider extends IInstallationDirectoryProvider {
10 | public getInstallDir(installId: string): string {
11 | const dotnetInstallDir = path.join(this.getStoragePath(), installId);
12 | return dotnetInstallDir;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Acquisition/SdkInstallationDirectoryProvider.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | import { IInstallationDirectoryProvider } from './IInstallationDirectoryProvider';
7 |
8 | export class SdkInstallationDirectoryProvider extends IInstallationDirectoryProvider {
9 | public getInstallDir(installId: string): string {
10 | return this.getStoragePath();
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Acquisition/StringConstants.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | import { DotnetInstall } from './DotnetInstall';
7 | import { IInstallationDirectoryProvider } from './IInstallationDirectoryProvider';
8 |
9 |
10 | /*
11 | * @remarks Hold this when using an installer that impacts the entire system state (not just user local state.)
12 | * This lock is unaware of external programs running MSIs that may conflict and also edit the global machine state.
13 | * But, it at least prevents the extension from tripping over itself.
14 | */
15 | export function GLOBAL_INSTALL_STATE_MODIFIER_LOCK(directoryProvider: IInstallationDirectoryProvider, install: DotnetInstall): string
16 | {
17 | return 'vscdGlLk';
18 | }
19 |
20 | export function RUN_UNDER_SUDO_LOCK(sudoDirectory: string): string
21 | {
22 | return 'vscdSudoLk';
23 | }
24 |
25 | export const UNABLE_TO_ACQUIRE_GLOBAL_LOCK_ERR = '898998';
26 |
27 | export const UBUNTU_DISTRO_INFO_KEY = 'Ubuntu';
28 | export const RED_HAT_DISTRO_INFO_KEY = 'Red Hat Enterprise Linux';
29 | export const DEBIAN_DISTRO_INFO_KEY = 'Debian GNU/Linux';
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/DotnetVersionSpecRequirement.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 | /**
6 | * @remarks A condition to be met when searching for .NET. This refers to the major.minor of .NET versions.
7 | * When this condition is used, the available version is compared to the required version.
8 | * For example, if the request is made looking for 8.0 and allowing 'greater_than_or_equal', then 10.0 would be accepted,
9 | * because 10.0 >= 8.0.
10 | *
11 | * In addition, certain values from globalJson's rollForward property are allowed.
12 |
13 | latestPatch - Uses the latest installed patch level that matches the requested major, minor, and feature band with a patch level that's greater than or equal to the specified value.
14 | If not found, fails. (in other words, 200 is not ok if we want 102.)
15 |
16 | latestFeature Uses the highest installed feature band and patch level that matches the requested major and minor with a feature band and patch level that's greater than or equal to the specified value.
17 | If not found, fails. (in other words, 200 is ok if we want 102, but 101 is not)
18 |
19 | latestMajor This is the same as greater_than_or_equal.
20 |
21 | disable - this is the same as equal.
22 | */
23 | export type DotnetVersionSpecRequirement = 'equal' | 'greater_than_or_equal' | 'less_than_or_equal' |
24 | 'latestPatch' | 'latestFeature' | 'latestMajor' | 'disable'; // latestMinor not implemented since minor has not been used since 3.1
25 |
26 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/EventStream/EventStream.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | import * as vscode from 'vscode';
7 | import { IEvent } from './IEvent';
8 |
9 | export interface IEventStream {
10 | post(event: IEvent): void;
11 | }
12 |
13 | export class EventStream implements IEventStream {
14 | private readonly subscribeEmitter: vscode.EventEmitter;
15 |
16 | constructor() {
17 | this.subscribeEmitter = new vscode.EventEmitter();
18 | }
19 |
20 | public post(event: IEvent) {
21 | this.subscribeEmitter.fire(event);
22 | }
23 |
24 | public get subscribe() { return this.subscribeEmitter.event; }
25 | }
26 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/EventStream/EventType.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | export enum EventType
7 | {
8 | DotnetAcquisitionStart,
9 | DotnetSDKAcquisitionStart,
10 | DotnetRuntimeAcquisitionStart,
11 | DotnetASPNetRuntimeAcquisitionStarted,
12 | DotnetAcquisitionCompleted,
13 | DotnetAcquisitionError,
14 | DotnetAcquisitionFinalError,
15 | DotnetAcquisitionSuccessEvent,
16 | DotnetAcquisitionMessage,
17 | DotnetAcquisitionTest,
18 | DotnetAcquisitionAlreadyInstalled,
19 | DotnetAcquisitionInProgress,
20 | DotnetUninstallMessage,
21 | DotnetDebuggingMessage,
22 | DotnetTotalSuccessEvent,
23 | OfflineInstallUsed,
24 | OfflineWarning,
25 | DotnetUpgradedEvent,
26 | SuppressedAcquisitionError,
27 | DotnetVisibleWarning,
28 | DotnetInstallExpectedAbort,
29 | DotnetModalChildEvent, // For sub-events that are published as a more specific version of an existing published generic event.
30 | // Example: DotnetAcquisitionStarted -> Children events are RuntimeStarted, SDKStarted, etc.
31 | FeedInjectionMessage,
32 | }
33 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/EventStream/IEvent.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | import { sanitizeProperties } from '../Utils/ContentSantizer';
7 | import { EventType } from './EventType';
8 |
9 | export abstract class IEvent {
10 | public abstract type: EventType;
11 |
12 | public abstract readonly eventName: string;
13 |
14 | public isError = false;
15 |
16 | public abstract getProperties(telemetry?: boolean): { [key: string]: string } | undefined;
17 |
18 | public getSanitizedProperties(): { [key: string]: string } | undefined {
19 | return sanitizeProperties(this.getProperties(true));
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/EventStream/IEventStreamObserver.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | import * as vscode from 'vscode';
7 | import { IEvent } from './IEvent';
8 |
9 | export interface IEventStreamObserver extends vscode.Disposable {
10 | post(event: IEvent): void;
11 | dispose(): void;
12 | }
13 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/EventStream/ILoggingObserver.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 | import { IEvent } from './IEvent';
6 | import { IEventStreamObserver } from './IEventStreamObserver';
7 |
8 | export interface ILoggingObserver extends IEventStreamObserver {
9 | post(event: IEvent): void;
10 | dispose(): void;
11 | getFileLocation(): string;
12 | }
13 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/EventStream/IModalEventPublisher.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 | import { IEvent } from './IEvent';
6 | import { IEventStreamObserver } from './IEventStreamObserver';
7 |
8 | export interface IModalEventRepublisher extends IEventStreamObserver
9 | {
10 | post(event: IEvent): void;
11 | dispose(): void;
12 | }
13 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/EventStream/IWindowDisplayWorker.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | export interface IWindowDisplayWorker
7 | {
8 | showErrorMessage(message: string, callback: (response: string | undefined) => Promise, ...items: string[]): void;
9 | showWarningMessage(message: string, callback: (response: string | undefined) => void, ...items: string[]): void;
10 | getModalWarningResponse(message: string, no: string, yes: string): Promise;
11 | showInformationMessage(message: string, callback: (response: string | undefined) => void, ...items: string[]): void;
12 | copyToUserClipboard(text: string): Promise;
13 | displayPathConfigPopUp(): Thenable;
14 | }
15 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/EventStream/LoggingObserver.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 | import * as fs from 'fs';
6 | import { IEvent } from './IEvent';
7 | import { ILoggingObserver } from './ILoggingObserver';
8 |
9 | export class LoggingObserver implements ILoggingObserver
10 | {
11 | private log: string[] = [];
12 |
13 | constructor(private readonly logFilePath: string) {}
14 |
15 | public post(event: IEvent): void
16 | {
17 | this.writeLine(`${new Date().toLocaleString()} ${new Date().getMilliseconds()} ${event.eventName}`);
18 | const properties = event.getProperties();
19 | if (properties)
20 | {
21 | for (const property of Object.values(properties))
22 | {
23 | this.writeLine(property);
24 | }
25 | }
26 | this.writeLine('');
27 | }
28 |
29 | public dispose(): void
30 | {
31 | fs.writeFileSync(this.logFilePath, this.log.join('\n'));
32 | }
33 |
34 | public getFileLocation(): string
35 | {
36 | return this.logFilePath;
37 | }
38 |
39 | private writeLine(line: string)
40 | {
41 | this.log.push(line);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/EventStream/StatusBarObserver.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | import * as vscode from 'vscode';
7 | import { EventType } from './EventType';
8 | import { IEvent } from './IEvent';
9 | import { IEventStreamObserver } from './IEventStreamObserver';
10 |
11 | enum StatusBarColors {
12 | Red = 'rgb(218,0,0)',
13 | Green = 'rgb(0,218,0)',
14 | }
15 |
16 | export class StatusBarObserver implements IEventStreamObserver {
17 | constructor(private readonly statusBarItem: vscode.StatusBarItem, private readonly showLogCommand: string) {
18 | }
19 |
20 | public post(event: IEvent): void {
21 | switch (event.type) {
22 | case EventType.DotnetAcquisitionStart:
23 | this.setAndShowStatusBar('$(cloud-download) Downloading .NET...', this.showLogCommand, '', 'Downloading .NET...');
24 | break;
25 | case EventType.DotnetAcquisitionCompleted:
26 | case EventType.DotnetInstallExpectedAbort:
27 | this.resetAndHideStatusBar();
28 | break;
29 | case EventType.DotnetAcquisitionError:
30 | this.setAndShowStatusBar('$(alert) Error acquiring .NET!', this.showLogCommand, StatusBarColors.Red, 'Error acquiring .NET');
31 | break;
32 | }
33 | }
34 |
35 | public dispose(): void {
36 | // Nothing to dispose
37 |
38 | }
39 |
40 | public setAndShowStatusBar(text: string, command: string, color?: string, tooltip?: string) {
41 | this.statusBarItem.text = text;
42 | this.statusBarItem.command = command;
43 | this.statusBarItem.color = color;
44 | this.statusBarItem.tooltip = tooltip;
45 | this.statusBarItem.show();
46 | }
47 |
48 | public resetAndHideStatusBar() {
49 | this.statusBarItem.text = '';
50 | this.statusBarItem.command = undefined;
51 | this.statusBarItem.color = undefined;
52 | this.statusBarItem.tooltip = undefined;
53 | this.statusBarItem.hide();
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/EventStream/WindowDisplayWorker.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 | import * as os from 'os';
6 | import { env, window } from 'vscode';
7 | import { IWindowDisplayWorker } from './IWindowDisplayWorker';
8 | /* eslint-disable */ // When editing this file, please remove this and fix the linting concerns.
9 |
10 |
11 | export class WindowDisplayWorker implements IWindowDisplayWorker {
12 | private readonly pathPlaceholder = os.platform() === 'win32' ? 'C:\\Program Files\\dotnet\\dotnet.exe' : '/usr/local/share/dotnet/dotnet';
13 | private readonly pathPrompt = 'Enter the path to the .NET executable. .NET can be installed at aka.ms/dotnet-download';
14 |
15 | public showErrorMessage(message: string, callback: (response: string| undefined) => void, ...items: string[]): void {
16 | window.showErrorMessage(message, ...items).then(async (response: string | undefined) => callback(response) );
17 | }
18 |
19 | public showWarningMessage(message: string, callback: (response: string| undefined) => void, ...items: string[]): void {
20 | window.showWarningMessage(message, ...items).then(async (response: string | undefined) => callback(response) );
21 | }
22 |
23 | public async getModalWarningResponse(message : string, no : string, yes : string) : Promise
24 | {
25 | return window.showWarningMessage(message, { modal: true }, no, yes);
26 | }
27 |
28 | public showInformationMessage(message: string, callback: (response: string | undefined) => void, ...items: string[]): void {
29 | window.showInformationMessage(message).then(async (response: string | undefined) => callback(response) );
30 | }
31 |
32 | public async copyToUserClipboard(text: string): Promise {
33 | await env.clipboard.writeText(text);
34 | }
35 |
36 | public displayPathConfigPopUp(): Thenable {
37 | return window.showInputBox({ value: this.pathPlaceholder, prompt: this.pathPrompt, ignoreFocusOut: true });
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/IDotnetAcquireContext.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | import { DotnetInstallMode as DotnetInstallMode } from './Acquisition/DotnetInstallMode';
7 | import { AcquireErrorConfiguration } from './Utils/ErrorHandler';
8 |
9 | export interface IDotnetAcquireContext
10 | {
11 | /**
12 | * @remarks
13 | * The data required to acquire either the sdk or the runtimes.
14 | *
15 | * @property version - The major.minor version of the SDK or Runtime desired.
16 | *
17 | * NOTE: For global SDK installations, more options are available.
18 | * The version can be provided in the following format in this acquisition:
19 | * Major (e.g: 6)
20 | * Major.Minor (e.g: 3.1)
21 | * Feature Band (e.g: 7.0.1xx or 7.0.10x)
22 | * Specific Version / Fully-Qualified Version (e.g: 8.0.103)
23 | *
24 | * @property requestingExtensionId - The Extension that relies on our extension to acquire the runtime or .NET SDK. It MUST be provided.
25 | *
26 | * @property errorConfiguration - An set of options for the desired treat as error and error verbosity behaviors of the extension.
27 | *
28 | * @property installType - For SDK installations, allows either global or local installs.
29 | * Do NOT use the local install feature with the global install feature or any global install as it is currently unsupported.
30 | *
31 | * @property architecture - null is for deliberate legacy install behavior that is not-architecture specific.
32 | * undefined is for the default of node.arch().
33 | * Does NOT impact global installs yet, it will be ignored. Follows node architecture terminology.
34 | *
35 | * @property mode - Whether the install should be of the sdk, runtime, aspnet runtime, or windowsdesktop runtime.
36 | * For example, set to 'aspnetcore' to install the aspnet runtime.
37 | * Defaults to 'runtime' as this was the default choice before this existed.
38 | * Note: If you try to call an install SDK endpoint or install runtime endpoint with a conflicting mode set, the mode will be ignored.
39 | * Only certain install types / modes combinations are supported at this time, such as local runtimes, local aspnet, and global SDKs.
40 | */
41 | version: string;
42 | requestingExtensionId?: string;
43 | errorConfiguration?: AcquireErrorConfiguration;
44 | installType?: DotnetInstallType;
45 | architecture?: string | null | undefined;
46 | mode? : DotnetInstallMode;
47 | }
48 |
49 | /**
50 | * @remarks
51 | * Defines if an install should be global on the machine or local to a specific local folder/user.
52 | */
53 | export type DotnetInstallType = 'local' | 'global';
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/IDotnetAcquireResult.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | export interface IDotnetAcquireResult {
7 | dotnetPath: string;
8 | }
9 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/IDotnetEnsureDependenciesContext.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 | import * as cp from 'child_process';
6 | import { EnsureDependenciesErrorConfiguration } from './Utils/ErrorHandler';
7 |
8 | export interface IDotnetEnsureDependenciesContext {
9 | command: string;
10 | arguments: cp.SpawnSyncOptionsWithStringEncoding;
11 | errorConfiguration?: EnsureDependenciesErrorConfiguration;
12 | }
13 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/IDotnetFindPathContext.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | import { DotnetVersionSpecRequirement } from './DotnetVersionSpecRequirement';
7 | import { IDotnetAcquireContext } from './IDotnetAcquireContext';
8 |
9 | export interface IDotnetFindPathContext
10 | {
11 | acquireContext: IDotnetAcquireContext;
12 | versionSpecRequirement: DotnetVersionSpecRequirement;
13 | rejectPreviews?: boolean;
14 | }
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/IDotnetListVersionsContext.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | import { AcquireErrorConfiguration } from './Utils/ErrorHandler';
7 |
8 | export interface IDotnetListVersionsContext {
9 | /**
10 | * @remarks
11 | * Holds the parameters necessary to acquire the available SDK or Runtimes.
12 | * By available this means only those at the newest minor version for each major version.
13 | *
14 | * @property listRuntimes - If this is not true (false or undefined), list SDK versions available. Elsewise, list runtimes available.
15 | * @property errorConfiguration - Do we want to show pop-ups for errors? Use this for this option and other options in the event of an error.
16 | */
17 | listRuntimes: boolean | null,
18 | errorConfiguration?: AcquireErrorConfiguration;
19 | }
20 |
21 | /**
22 | * @remarks
23 | * The result/response from the API to be implemented that returns available SDKs/Runtimes.
24 | */
25 | export type IDotnetListVersionsResult = IDotnetVersion[]
26 |
27 | export interface IDotnetVersion {
28 | /**
29 | * @remarks
30 | * Information regarding the version of the .NET SDK / Runtime.
31 | *
32 | * @property version - The full version of the SDK or Runtime. May include text such as -Preview.
33 | * @property channelVersion - The major.minor version.
34 | * @property supportPhase - Whether the version is actively in support or in some other stage of support.
35 | * @property supportStatus - Is the version in long-term support or 'standard-term' support
36 | */
37 | version: string,
38 | supportStatus: DotnetVersionSupportStatus,
39 | supportPhase: DotnetVersionSupportPhase,
40 | channelVersion: string,
41 | }
42 |
43 | /**
44 | * @remarks
45 | * lts: Long-term support
46 | * sts: Standard-term support
47 | */
48 | export type DotnetVersionSupportStatus = 'lts' | 'sts';
49 |
50 | /**
51 | * @remarks
52 | * preview support does not mean the development is stable and actively supported.
53 | */
54 | export type DotnetVersionSupportPhase = 'active' | 'preview' | 'eol' | 'go-live' | 'maintenance';
55 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/IDotnetUninstallContext.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | import { UninstallErrorConfiguration } from './Utils/ErrorHandler';
7 |
8 | export interface IDotnetUninstallContext {
9 | errorConfiguration?: UninstallErrorConfiguration;
10 | }
11 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/IExtensionContext.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 | import { IWindowDisplayWorker } from './EventStream/IWindowDisplayWorker';
6 | import { ITelemetryReporter } from './EventStream/TelemetryObserver';
7 |
8 | export interface IExtensionContext {
9 | telemetryReporter: ITelemetryReporter | undefined;
10 | extensionConfiguration: IExtensionConfiguration;
11 | displayWorker: IWindowDisplayWorker;
12 | }
13 |
14 | export interface IExtensionConfiguration {
15 | get(name: string): T | undefined;
16 | update(section: string, value: T, globalSettings: boolean): Thenable;
17 | }
18 |
19 | export namespace ExistingPathKeys {
20 | export const extensionIdKey = 'extensionId';
21 | export const pathKey = 'path';
22 | }
23 |
24 | export interface ILocalExistingPath {
25 | [ExistingPathKeys.extensionIdKey]: string;
26 | [ExistingPathKeys.pathKey]: string;
27 | }
28 |
29 | export interface IExistingPaths {
30 | individualizedExtensionPaths?: ILocalExistingPath[];
31 | sharedExistingPath? : string;
32 | }
33 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/IExtensionState.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | import { Memento } from 'vscode';
7 |
8 | export type IExtensionState = Memento
9 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/IVSCodeExtensionContext.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | export abstract class IVSCodeExtensionContext
7 | {
8 | abstract setVSCodeEnvironmentVariable(variable : string, value : string) : void;
9 |
10 | abstract appendToEnvironmentVariable(variable : string, pathAdditionWithDelimiter : string) : void;
11 |
12 | abstract registerOnExtensionChange(f: (...args: A) => R, ...args: A) : void;
13 |
14 | abstract getExtensions() : readonly any[];
15 |
16 | abstract executeCommand(command : string, ...args: any[]) : Thenable;
17 | }
18 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Utils/CommandExecutorCommand.ts:
--------------------------------------------------------------------------------
1 | /* --------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | * Licensed under the MIT License. See License.txt in the project root for license information.
5 | * ------------------------------------------------------------------------------------------ */
6 |
7 | export type CommandExecutorCommand =
8 | {
9 | /**
10 | * @property commandRoot
11 | * The command first 'word' to run, example: 'dotnet --info' has a first word of 'dotnet'
12 | * @property commandParts
13 | * The remaining strings in the command to execute, example: 'dotnet build foo.csproj' will be ['build', 'foo.csproj']
14 | * @property runUnderSudo
15 | * Use this if the command should be executed under sudo on linux.
16 | */
17 | commandRoot : string,
18 | commandParts : string[],
19 | runUnderSudo : boolean
20 | }
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Utils/CommandExecutorResult.ts:
--------------------------------------------------------------------------------
1 | /* --------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | * Licensed under the MIT License. See License.txt in the project root for license information.
5 | * ------------------------------------------------------------------------------------------ */
6 |
7 | export type CommandExecutorResult =
8 | {
9 | /**
10 | * @property commandRoot
11 | * The stdout of the command.
12 | * @property commandParts
13 | * The stderr of the command.
14 | * @property status
15 | * The exit code of the program/command after execution.
16 | */
17 | stdout : string,
18 | stderr : string,
19 | status : string
20 | }
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Utils/ContentSantizer.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 | export function sanitize(content: string)
6 | {
7 | const user = process.env.USERNAME === undefined ? process.env.USER : process.env.USERNAME;
8 |
9 | if (user === undefined)
10 | {
11 | // Couldn't determine user, therefore can't truly sanitize the content.
12 | return content;
13 | }
14 |
15 | const replacer = new RegExp(user, 'g');
16 | const sanitizedContent = content.replace(replacer, 'anonymous');
17 | return sanitizedContent;
18 | }
19 |
20 | export function sanitizeProperties(properties: { [key: string]: string } | undefined): { [key: string]: string } | undefined
21 | {
22 | if (properties === undefined)
23 | {
24 | return properties;
25 | }
26 | const sanitizedProperties: { [key: string]: string } = {};
27 | for (const property of Object.keys(properties ?? {}))
28 | {
29 | sanitizedProperties[property] = sanitize(properties[property]);
30 | }
31 | return sanitizedProperties;
32 | }
33 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Utils/Debugging.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | import path = require('path');
7 | import { IEventStream } from '../EventStream/EventStream';
8 | import {
9 | DotnetDebuggingMessage,
10 | } from '../EventStream/EventStreamEvents';
11 | import * as fs from 'fs';
12 |
13 | /**
14 | * A simple wrapper around console logging that can disable / enable all debugging or logging messages.
15 | * Use EventStreamEvents for user facing debugging logs.
16 | */
17 | export class Debugging
18 | {
19 | static logFile = path.join(__dirname, 'VsDotnetDebuggingLog.txt');
20 | static debugOn = false;
21 | static logToTerminal = true;
22 | static logToFile = true;
23 |
24 | public static log(message : string, eventStream : IEventStream | null = null)
25 | {
26 | if(Debugging.debugOn)
27 | {
28 | if(Debugging.logToTerminal)
29 | {
30 | eventStream?.post(new DotnetDebuggingMessage(message));
31 | }
32 |
33 | console.log(message);
34 |
35 |
36 | if(Debugging.logFile)
37 |
38 | {
39 | console.log(`Writing to ${Debugging.logFile}`);
40 | if(Debugging.logToTerminal)
41 | {
42 | eventStream?.post(new DotnetDebuggingMessage(`Writing to ${Debugging.logFile}`));
43 | }
44 |
45 | const file = fs.createWriteStream(Debugging.logFile, { flags: 'a+' });
46 | file.write(message);
47 | }
48 | }
49 | }
50 | };
51 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Utils/ExtensionConfigurationWorker.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 | import { EventBasedError } from '../EventStream/EventStreamEvents';
6 | import { IExistingPaths, IExtensionConfiguration, ILocalExistingPath } from '../IExtensionContext';
7 | import { IExtensionConfigurationWorker } from './IExtensionConfigurationWorker';
8 |
9 | export class ExtensionConfigurationWorker implements IExtensionConfigurationWorker {
10 | constructor(private readonly extensionConfiguration: IExtensionConfiguration,
11 | private readonly pathConfigValueName: string | undefined,
12 | private readonly sharedExistingDotnetPath: string | undefined,
13 | private readonly unsupportedMessage = 'The shared existing path configuration is not supported.')
14 | {
15 |
16 | }
17 |
18 | public getAllPathConfigurationValues(): IExistingPaths | undefined
19 | {
20 | return {
21 | individualizedExtensionPaths : this.pathConfigValueName ? this.extensionConfiguration.get(this.pathConfigValueName) as ILocalExistingPath : undefined,
22 | sharedExistingPath : this.sharedExistingDotnetPath ? this.extensionConfiguration.get(this.sharedExistingDotnetPath) as string : undefined
23 | } as IExistingPaths;
24 | }
25 |
26 |
27 | public getSharedPathConfigurationValue(): string | undefined
28 | {
29 | if (!this.sharedExistingDotnetPath) {
30 | throw new EventBasedError('unsupportedSharedPathConfiguration', this.unsupportedMessage);
31 | }
32 | return this.pathConfigValueName ? this.extensionConfiguration.get(this.sharedExistingDotnetPath) : undefined;
33 | }
34 |
35 | public async setSharedPathConfigurationValue(configValue: string): Promise {
36 | if (!this.sharedExistingDotnetPath) {
37 | throw new EventBasedError('unsupportedSharedExistingPathConfiguration', this.unsupportedMessage);
38 | }
39 | await this.extensionConfiguration.update(this.sharedExistingDotnetPath, configValue, true);
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Utils/IExtensionConfigurationWorker.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | import { IExistingPaths } from '../IExtensionContext';
7 |
8 | export interface IExtensionConfigurationWorker
9 | {
10 | getAllPathConfigurationValues(): IExistingPaths | undefined;
11 | getSharedPathConfigurationValue(): string | undefined;
12 | setSharedPathConfigurationValue(configValue: string): Promise;
13 | }
14 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Utils/IFileUtilities.ts:
--------------------------------------------------------------------------------
1 | /* --------------------------------------------------------------------------------------------
2 | * Copyright (c) Microsoft Corporation. All rights reserved.
3 | * Licensed under the MIT License. See License.txt in the project root for license information.
4 | * ------------------------------------------------------------------------------------------ */
5 |
6 | import { IAcquisitionWorkerContext } from '../Acquisition/IAcquisitionWorkerContext';
7 | import { IEventStream } from '../EventStream/EventStream';
8 | import { IUtilityContext } from './IUtilityContext';
9 |
10 | export abstract class IFileUtilities
11 | {
12 | public abstract writeFileOntoDisk(scriptContent: string, filePath: string, eventStream?: IEventStream): Promise;
13 |
14 | /**
15 | * @param directoryToWipe the directory to delete all of the files in if privilege to do so exists.
16 | */
17 | public abstract wipeDirectory(directoryToWipe: string, eventStream?: IEventStream, fileExtensionsToDelete?: string[], verifyDotnetNotInUse?: boolean): Promise;
18 |
19 | /**
20 | *
21 | * @returns true if the process is running with admin privileges on windows.
22 | */
23 | public abstract isElevated(context: IAcquisitionWorkerContext, utilContext: IUtilityContext): Promise;
24 |
25 | public abstract getFileHash(filePath: string): Promise;
26 |
27 | public abstract exists(filePath: string): Promise;
28 |
29 | public abstract read(filePath: string): Promise;
30 |
31 | // return the realpath if possible and valid, else null
32 | public abstract realpath(filePath: string): Promise;
33 |
34 | };
35 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Utils/IIssueContext.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 | import { IEventStream } from '../EventStream/EventStream';
6 | import { ILoggingObserver } from '../EventStream/ILoggingObserver';
7 | import { IWindowDisplayWorker } from '../EventStream/IWindowDisplayWorker';
8 | import { ErrorConfiguration } from './ErrorHandler';
9 | import { IExtensionConfigurationWorker } from './IExtensionConfigurationWorker';
10 |
11 | export interface IIssueContext {
12 | logger: ILoggingObserver;
13 | errorConfiguration: ErrorConfiguration;
14 | displayWorker: IWindowDisplayWorker;
15 | extensionConfigWorker: IExtensionConfigurationWorker;
16 | eventStream: IEventStream;
17 | commandName: string;
18 | version: string | undefined;
19 | timeoutInfoUrl: string;
20 | moreInfoUrl: string;
21 | }
22 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Utils/IUtilityContext.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 | import { IWindowDisplayWorker } from '../EventStream/IWindowDisplayWorker';
6 | import { IVSCodeEnvironment } from './IVSCodeEnvironment';
7 |
8 | export interface IUtilityContext {
9 | ui : IWindowDisplayWorker;
10 | vsCodeEnv : IVSCodeEnvironment;
11 | }
12 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Utils/IVSCodeEnvironment.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | export abstract class IVSCodeEnvironment
7 | {
8 | /**
9 | * @returns True on success of setting environment for vscode.
10 | */
11 | abstract isTelemetryEnabled() : boolean;
12 | }
13 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Utils/IssueReporter.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 | import { sanitize } from './ContentSantizer';
6 | import { IIssueContext } from './IIssueContext';
7 |
8 | // Remove this when https://github.com/typescript-eslint/typescript-eslint/issues/2728 is done
9 | /* eslint-disable @typescript-eslint/no-unsafe-member-access */
10 |
11 | const packageJson = require('../../package.json');
12 | const issuesUrl = `https://github.com/dotnet/vscode-dotnet-runtime/issues/new/choose`;
13 |
14 | export function formatIssueUrl(error: Error | undefined, context: IIssueContext): [ string, string ] {
15 | context.logger.dispose(); // Ensure log file is up to date
16 |
17 | const errorMessage = !error ? '' : `**Error Message:** ${ sanitize(error!.message) }
18 | **Error Stack:** ${ error.stack === undefined ? '' : sanitize(error!.stack!) }`;
19 |
20 | const issueBody = `
21 |
22 | Please attach the log file located at ${ context.logger.getFileLocation() }. Note that this file may contain personal data.
23 |
24 | **Extension Version:** ${ packageJson?.version }
25 | ${ errorMessage }`;
26 |
27 | return [issuesUrl, issueBody];
28 | }
29 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Utils/LockUsedByThisInstanceSingleton.ts:
--------------------------------------------------------------------------------
1 | /* --------------------------------------------------------------------------------------------
2 | * Copyright (c) Microsoft Corporation. All rights reserved.
3 | * Licensed under the MIT License. See License.txt in the project root for license information.
4 | * ------------------------------------------------------------------------------------------ */
5 |
6 | import * as crypto from 'crypto';
7 |
8 | export class LockUsedByThisInstanceSingleton
9 | {
10 | protected static instance: LockUsedByThisInstanceSingleton;
11 |
12 | private everSpawnedSudoSuccessfully = false;
13 | private currentAliveStatus = false;
14 | private sudoError: any = null;
15 |
16 | public static readonly SUDO_SESSION_ID = crypto.randomUUID().substring(0, 8);
17 |
18 | protected constructor(protected lockStringAndThisVsCodeInstanceOwnsIt: { [lockString: string]: boolean } = {})
19 | {
20 |
21 | }
22 |
23 | public static getInstance(): LockUsedByThisInstanceSingleton
24 | {
25 | if (!LockUsedByThisInstanceSingleton.instance)
26 | {
27 | LockUsedByThisInstanceSingleton.instance = new LockUsedByThisInstanceSingleton();
28 | }
29 |
30 | return LockUsedByThisInstanceSingleton.instance;
31 | }
32 |
33 | public hasSpawnedSudoSuccessfullyWithoutDeath(): boolean
34 | {
35 | return this.everSpawnedSudoSuccessfully;
36 | }
37 |
38 | public killingSudoProc(): void
39 | {
40 | this.everSpawnedSudoSuccessfully = false;
41 | }
42 |
43 | public isCurrentSudoProcCheckAlive(): boolean
44 | {
45 | return this.currentAliveStatus;
46 | }
47 |
48 | /*
49 | You must set it back to false when the check is done.
50 | */
51 | public setCurrentSudoCheckAsAlive(alive: boolean): void
52 | {
53 | if (alive)
54 | {
55 | this.everSpawnedSudoSuccessfully = true;
56 | }
57 | this.currentAliveStatus = alive;
58 | }
59 |
60 | public sudoProcError(): any
61 | {
62 | return this.sudoError;
63 | }
64 |
65 | public setSudoProcError(err: any): void
66 | {
67 | this.sudoError = err;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/Utils/VSCodeEnvironment.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | import { IVSCodeEnvironment } from './IVSCodeEnvironment';
7 | import * as vscode from 'vscode';
8 |
9 | export class VSCodeEnvironment extends IVSCodeEnvironment
10 | {
11 | constructor()
12 | {
13 | super();
14 | }
15 |
16 | isTelemetryEnabled(): boolean
17 | {
18 | return vscode.env.isTelemetryEnabled;
19 | }
20 | }
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/VSCodeExtensionContext.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | import { IVSCodeExtensionContext } from './IVSCodeExtensionContext';
7 | import * as vscode from 'vscode';
8 |
9 | export class VSCodeExtensionContext extends IVSCodeExtensionContext
10 | {
11 | private context: vscode.ExtensionContext;
12 |
13 | constructor(trueContext: vscode.ExtensionContext)
14 | {
15 | super();
16 | this.context = trueContext;
17 | }
18 |
19 | public setVSCodeEnvironmentVariable(variable: string, value: string): void
20 | {
21 | const environment = this.context.environmentVariableCollection;
22 | environment.replace(variable, value);
23 | }
24 |
25 | public appendToEnvironmentVariable(variable: string, appendingValue: string): void
26 | {
27 | const environment = this.context.environmentVariableCollection;
28 | environment?.append(variable, appendingValue);
29 | }
30 |
31 | public registerOnExtensionChange(f: (...args: A) => R, ...args: A): void
32 | {
33 | vscode.extensions.onDidChange(() =>
34 | {
35 | f(...(args));
36 | })
37 | }
38 |
39 | public getExtensions(): readonly vscode.Extension[]
40 | {
41 | return vscode.extensions.all;
42 | }
43 |
44 | public executeCommand(command: string, ...args: any[]): Thenable
45 | {
46 | return vscode.commands.executeCommand(command, ...args);
47 | }
48 | }
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/index.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | export * from './Acquisition/AcquisitionInvoker';
7 | export * from './Acquisition/DirectoryProviderFactory';
8 | export * from './Acquisition/DotnetConditionValidator';
9 | export * from './Acquisition/DotnetCoreAcquisitionWorker';
10 | export * from './Acquisition/DotnetCoreDependencyInstaller';
11 | export * from './Acquisition/DotnetInstall';
12 | export * from './Acquisition/DotnetInstallMode';
13 | export * from './Acquisition/DotnetPathFinder';
14 | export * from './Acquisition/ExistingPathResolver';
15 | export * from './Acquisition/GenericDistroSDKProvider';
16 | export * from './Acquisition/GlobalInstallerResolver';
17 | export * from './Acquisition/IAcquisitionWorkerContext';
18 | export * from './Acquisition/IDotnetConditionValidator';
19 | export * from './Acquisition/IDotnetListInfo';
20 | export * from './Acquisition/IDotnetPathFinder';
21 | export * from './Acquisition/IInstallationDirectoryProvider';
22 | export * from './Acquisition/IJsonInstaller';
23 | export * from './Acquisition/InstallationValidator';
24 | export * from './Acquisition/InstallRecord';
25 | export * from './Acquisition/InstallRecordWithPath';
26 | export * from './Acquisition/IVersionResolver';
27 | export * from './Acquisition/JsonInstaller';
28 | export * from './Acquisition/LinuxGlobalInstaller';
29 | export * from './Acquisition/LinuxVersionResolver';
30 | export * from './Acquisition/RuntimeInstallationDirectoryProvider';
31 | export * from './Acquisition/SdkInstallationDirectoryProvider';
32 | export * from './Acquisition/VersionResolver';
33 | export * from './Acquisition/VersionUtilities';
34 | export * from './Acquisition/WinMacGlobalInstaller';
35 | export * from './DotnetVersionSpecRequirement';
36 | export * from './EventStream/EventStream';
37 | export * from './EventStream/EventStreamEvents';
38 | export * from './EventStream/EventStreamRegistration';
39 | export * from './EventStream/IWindowDisplayWorker';
40 | export * from './EventStream/WindowDisplayWorker';
41 | export * from './IDotnetAcquireContext';
42 | export * from './IDotnetAcquireResult';
43 | export * from './IDotnetEnsureDependenciesContext';
44 | export * from './IDotnetFindPathContext';
45 | export * from './IDotnetListVersionsContext';
46 | export * from './IDotnetUninstallContext';
47 | export * from './IExtensionContext';
48 | export * from './IExtensionState';
49 | export * from './IVSCodeExtensionContext';
50 | export * from './LocalMemoryCacheSingleton';
51 | export * from './test/mocks/MockEnvironmentVariableCollection';
52 | export * from './test/mocks/MockObjects';
53 | export * from './test/mocks/MockWindowDisplayWorker';
54 | export * from './test/unit/TestUtility';
55 | export * from './Utils/CommandExecutor';
56 | export * from './Utils/Debugging';
57 | export * from './Utils/ErrorHandler';
58 | export * from './Utils/ExtensionConfigurationWorker';
59 | export * from './Utils/FileUtilities';
60 | export * from './Utils/ICommandExecutor';
61 | export * from './Utils/IFileUtilities';
62 | export * from './Utils/IIssueContext';
63 | export * from './Utils/InstallIdUtilities';
64 | export * from './Utils/IssueReporter';
65 | export * from './Utils/IUtilityContext';
66 | export * from './Utils/IVSCodeEnvironment';
67 | export * from './Utils/TypescriptUtilities';
68 | export * from './Utils/VSCodeEnvironment';
69 | export * from './Utils/WebRequestWorkerSingleton';
70 | export * from './VSCodeExtensionContext';
71 |
72 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/test/mocks/MockEnvironmentVariableCollection.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 | import * as vscode from 'vscode';
6 |
7 | export class MockEnvironmentVariableCollection implements vscode.EnvironmentVariableCollection {
8 |
9 | public persistent = true;
10 | public variables: {[variable: string]: string} = {};
11 |
12 | public append(variable: string, value: string): void {
13 | const envVar = this.variables[variable];
14 | if (envVar === undefined) {
15 | this.variables[variable] = value;
16 | } else {
17 | this.variables[variable] = this.variables[variable] + value;
18 | }
19 | }
20 |
21 | public get(variable: string): vscode.EnvironmentVariableMutator | undefined {
22 | throw new Error('Method not implemented.');
23 | }
24 |
25 | public replace(variable: string, value: string): void {
26 | this.variables[variable] = value;
27 | }
28 |
29 |
30 | public prepend(variable: string, value: string): void {
31 | throw new Error('Method not implemented.');
32 | }
33 |
34 | public forEach(callback: (variable: string, mutator: vscode.EnvironmentVariableMutator, collection: vscode.EnvironmentVariableCollection) => any, thisArg?: any): void {
35 | throw new Error('Method not implemented.');
36 | }
37 |
38 | public delete(variable: string): void {
39 | throw new Error('Method not implemented.');
40 | }
41 |
42 | public clear(): void {
43 | throw new Error('Method not implemented.');
44 | }
45 |
46 | [Symbol.iterator](): Iterator<[variable: string, mutator: vscode.EnvironmentVariableMutator], any, undefined> {
47 | throw new Error('Method not implemented.');
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/test/mocks/MockExtensionConfigurationWorker.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 | import { ExistingPathKeys, IExistingPaths, ILocalExistingPath} from '../../IExtensionContext';
6 | import { ExtensionConfigurationWorker } from '../../Utils/ExtensionConfigurationWorker';
7 | import { IExtensionConfigurationWorker } from '../../Utils/IExtensionConfigurationWorker';
8 |
9 | export class MockExtensionConfigurationWorker implements IExtensionConfigurationWorker {
10 | constructor(
11 | private mockPaths: IExistingPaths = {
12 | individualizedExtensionPaths: [{ [ExistingPathKeys.extensionIdKey]: 'MockRequestingExtensionId', [ExistingPathKeys.pathKey] : 'MockPath' }],
13 | sharedExistingPath: 'MockGlobalPath'}
14 | ) {}
15 |
16 | async setPathConfigurationValue(configValue: string, setGlobalSetting: boolean): Promise {
17 | setGlobalSetting ? this.setSharedPathConfigurationValue(configValue) :
18 | this.setLocalPathConfigurationValue([{ [ExistingPathKeys.extensionIdKey]: 'MockRequestingExtensionId', [ExistingPathKeys.pathKey] : configValue }]);
19 | }
20 |
21 | public getAllPathConfigurationValues(): IExistingPaths | undefined {
22 | return this.mockPaths;
23 | }
24 |
25 | public getSharedPathConfigurationValue(): string | undefined {
26 | return this.mockPaths.sharedExistingPath;
27 | }
28 |
29 | public setLocalPathConfigurationValue(configValue: ILocalExistingPath[]): Promise {
30 | this.mockPaths.individualizedExtensionPaths = configValue;
31 | return new Promise((resolve) => { resolve(); });
32 | }
33 |
34 | public setSharedPathConfigurationValue(configValue: string): Promise {
35 | this.mockPaths.sharedExistingPath = configValue;
36 | return new Promise((resolve) => { resolve(); });
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/test/mocks/MockRunTask.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | import { exit } from 'process';
7 | import { INodeIPCTestLogger, printWithLock } from '../unit/TestUtility';
8 |
9 | process.on('message', async (msg: any) =>
10 | {
11 | if (msg?.run)
12 | {
13 | const logger = new INodeIPCTestLogger(); // The logger passed is not a class but list of events.
14 | await printWithLock(process.argv[4], process.argv[2], Number(process.argv[3]), logger,
15 | async () =>
16 | {
17 | console.log(`Send update: ${logger.logs}`);
18 | process.send?.({ status: 'update', message: logger.logs });
19 | logger.logs = []; // Clear the logs to avoid sending the same message multiple times.
20 | }
21 | );
22 | exit(0);
23 | }
24 | });
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/test/mocks/MockWindowDisplayWorker.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 | import { IWindowDisplayWorker } from '../../EventStream/IWindowDisplayWorker';
6 |
7 | export class MockWindowDisplayWorker implements IWindowDisplayWorker {
8 |
9 | public errorMessage = '';
10 | public warningMessage = '';
11 | public infoMessage = '';
12 | public clipboardText = '';
13 | public options: string[] = [];
14 | public callback: ((response: string| undefined) => void | Promise) | undefined = undefined;
15 | constructor(private readonly mockPath = 'MockPath') { }
16 |
17 | public showErrorMessage(message: string, callback: (response: string| undefined) => void | Promise, ...items: string[]): void {
18 | this.errorMessage = message;
19 | this.options = items;
20 | this.callback = callback;
21 | }
22 |
23 | public showWarningMessage(message: string, callback: (response: string| undefined) => void | Promise, ...items: string[]): void {
24 | this.warningMessage = message;
25 | this.options = items;
26 | this.callback = callback;
27 | }
28 |
29 | public showInformationMessage(message: string, callback: (response: string | undefined) => void | Promise, ...items: string[]): void {
30 | this.infoMessage = message;
31 | this.callback = callback;
32 | }
33 |
34 | public async copyToUserClipboard(text: string): Promise {
35 | this.clipboardText = text;
36 | }
37 |
38 | public async getModalWarningResponse(message: string, no: string, yes: string): Promise {
39 | return true;
40 | }
41 |
42 | public displayPathConfigPopUp(): Promise {
43 | return new Promise((resolve) => { resolve(this.mockPath); });
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/test/mocks/mock-releases.json:
--------------------------------------------------------------------------------
1 | {
2 | "releases-index": [
3 | {
4 | "channel-version": "2.2",
5 | "latest-release": "2.2.8",
6 | "latest-release-date": "2019-11-19",
7 | "security": true,
8 | "latest-runtime": "2.2.8",
9 | "latest-sdk": "2.2.207",
10 | "product": ".NET Core",
11 | "support-phase": "maintenance",
12 | "release-type" : "lts",
13 | "eol-date": "2019-12-23",
14 | "releases.json": "https://builds.dotnet.microsoft.com/dotnet/release-metadata/2.2/releases.json"
15 | },
16 | {
17 | "channel-version": "2.1",
18 | "latest-release": "2.1.14",
19 | "latest-release-date": "2019-11-19",
20 | "security": true,
21 | "latest-runtime": "2.1.14",
22 | "latest-sdk": "2.1.607",
23 | "product": ".NET Core",
24 | "release-type" : "lts",
25 | "support-phase": "lts",
26 | "eol-date": null,
27 | "releases.json": "https://builds.dotnet.microsoft.com/dotnet/release-metadata/2.1/releases.json"
28 | },
29 | {
30 | "channel-version": "2.0",
31 | "latest-release": "2.0.9",
32 | "latest-release-date":"2018-07-10",
33 | "security": true,
34 | "latest-runtime": "2.0.9",
35 | "latest-sdk": "2.1.202",
36 | "product": ".NET Core",
37 | "release-type" : "lts",
38 | "support-phase": "eol",
39 | "eol-date": "2018-10-01",
40 | "releases.json": "https://builds.dotnet.microsoft.com/dotnet/release-metadata/2.0/releases.json"
41 | },
42 | {
43 | "channel-version": "1.1",
44 | "latest-release": "1.1.13",
45 | "latest-release-date": "2019-05-14",
46 | "security": true,
47 | "latest-runtime": "1.1.13",
48 | "latest-sdk": "1.1.14",
49 | "product": ".NET Core",
50 | "release-type" : "lts",
51 | "support-phase": "eol",
52 | "eol-date": "2019-06-27",
53 | "releases.json": "https://builds.dotnet.microsoft.com/dotnet/release-metadata/1.1/releases.json"
54 | },
55 | {
56 | "channel-version": "1.0",
57 | "latest-release": "1.0.16",
58 | "latest-release-date": "2019-05-14",
59 | "security": true,
60 | "latest-runtime": "1.0.16",
61 | "latest-sdk": "1.1.14",
62 | "product": ".NET Core",
63 | "release-type" : "lts",
64 | "support-phase": "eol",
65 | "eol-date": "2019-06-27",
66 | "releases.json": "https://builds.dotnet.microsoft.com/dotnet/release-metadata/1.0/releases.json"
67 | }
68 | ]
69 | }
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/test/unit/InstallationValidator.test.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 | import * as chai from 'chai';
6 | import * as os from 'os';
7 | import { GetDotnetInstallInfo } from '../../Acquisition/DotnetInstall';
8 | import { InstallationValidator } from '../../Acquisition/InstallationValidator';
9 | import { LocalMemoryCacheSingleton } from '../../LocalMemoryCacheSingleton';
10 | import { WebRequestWorkerSingleton } from '../../Utils/WebRequestWorkerSingleton';
11 | import { MockEventStream } from '../mocks/MockObjects';
12 |
13 | const assert = chai.assert;
14 |
15 | suite('InstallationValidator Unit Tests', function ()
16 | {
17 | this.afterEach(async () =>
18 | {
19 | // Tear down tmp storage for fresh run
20 | WebRequestWorkerSingleton.getInstance().destroy();
21 | LocalMemoryCacheSingleton.getInstance().invalidate();
22 | });
23 |
24 | const eventStream = new MockEventStream();
25 | const validator = new InstallationValidator(eventStream);
26 |
27 | test('Error With Invalid File Structure', async () =>
28 | {
29 | const install = GetDotnetInstallInfo('7.0', 'runtime', 'local', os.arch());
30 | assert.throws(() => validator.validateDotnetInstall(install, ''), `Validation of .dotnet installation for version`);
31 | assert.throws(() => validator.validateDotnetInstall(install, ''), `fail`);
32 | });
33 | });
34 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/test/unit/IssueReporter.test.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 | import * as chai from 'chai';
6 | import { LocalMemoryCacheSingleton } from '../../LocalMemoryCacheSingleton';
7 | import { AcquireErrorConfiguration } from '../../Utils/ErrorHandler';
8 | import { formatIssueUrl } from '../../Utils/IssueReporter';
9 | import { WebRequestWorkerSingleton } from '../../Utils/WebRequestWorkerSingleton';
10 | import { MockExtensionConfigurationWorker } from '../mocks/MockExtensionConfigurationWorker';
11 | import { MockEventStream, MockLoggingObserver } from '../mocks/MockObjects';
12 | import { MockWindowDisplayWorker } from '../mocks/MockWindowDisplayWorker';
13 | const assert = chai.assert;
14 |
15 | suite('IssueReporter Unit Tests', function ()
16 | {
17 | this.afterEach(async () =>
18 | {
19 | // Tear down tmp storage for fresh run
20 | WebRequestWorkerSingleton.getInstance().destroy();
21 | LocalMemoryCacheSingleton.getInstance().invalidate();
22 | });
23 |
24 | test('Issue url is properly formed', async () =>
25 | {
26 | const [url, issueBody] = formatIssueUrl(
27 | new Error(),
28 | {
29 | logger: new MockLoggingObserver(),
30 | errorConfiguration: AcquireErrorConfiguration.DisableErrorPopups,
31 | displayWorker: new MockWindowDisplayWorker(),
32 | extensionConfigWorker: new MockExtensionConfigurationWorker(),
33 | commandName: 'test',
34 | eventStream: new MockEventStream(),
35 | version: '',
36 | moreInfoUrl: '',
37 | timeoutInfoUrl: '',
38 | });
39 |
40 | const expectedBodyContent = ['log', 'private'];
41 | for (const expected of expectedBodyContent)
42 | {
43 | assert.include(issueBody, expected);
44 | }
45 |
46 | const expectedUrlContent = ['new', 'vscode-dotnet-runtime', 'issues'];
47 | for (const expected of expectedUrlContent)
48 | {
49 | assert.include(url, expected);
50 | }
51 | });
52 | });
53 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/test/unit/JsonInstaller.test.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 | import * as chai from 'chai';
6 | import { JsonInstaller } from '../../Acquisition/JsonInstaller';
7 | import { DotnetVSCodeExtensionFound } from '../../EventStream/EventStreamEvents';
8 | import { LocalMemoryCacheSingleton } from '../../LocalMemoryCacheSingleton';
9 | import { WebRequestWorkerSingleton } from '../../Utils/WebRequestWorkerSingleton';
10 | import { MockEventStream, MockVSCodeExtensionContext } from '../mocks/MockObjects';
11 |
12 | const assert = chai.assert;
13 |
14 | suite('JSONInstaller Unit Tests', function ()
15 | {
16 | this.afterEach(async () =>
17 | {
18 | LocalMemoryCacheSingleton.getInstance().invalidate();
19 | WebRequestWorkerSingleton.getInstance().destroy();
20 | });
21 |
22 | const eventStream = new MockEventStream();
23 | const mockContext = new MockVSCodeExtensionContext();
24 |
25 | test('It Scans Extensions Without x-dotnet-acquire', async () =>
26 | {
27 | const _ = new JsonInstaller(eventStream, mockContext);
28 | const acquireEvent = eventStream.events.find(event => event instanceof DotnetVSCodeExtensionFound) as DotnetVSCodeExtensionFound;
29 |
30 | assert.exists(acquireEvent, 'The extensions were scanned, and did not cause an error with having an empty json value')
31 | });
32 | });
33 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/test/unit/LoggingObserver.test.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 | import * as chai from 'chai';
6 | import * as fs from 'fs';
7 | import * as path from 'path';
8 | import { DotnetUninstallAllStarted } from '../../EventStream/EventStreamEvents';
9 | import { LoggingObserver } from '../../EventStream/LoggingObserver';
10 | const assert = chai.assert;
11 |
12 | suite('LoggingObserver Unit Tests', () =>
13 | {
14 | const tempPath = path.join(__dirname, `${new Date().getTime()}`);
15 |
16 | test('Log file is writing output', async () =>
17 | {
18 | // Create an empty folder
19 | if (!fs.existsSync(tempPath))
20 | {
21 | fs.mkdirSync(tempPath);
22 | }
23 | // Create a logging observer
24 | const loggingObserver = new LoggingObserver(path.join(tempPath, 'logTest.txt'));
25 |
26 | // Create a fake event and call the post/dispose function
27 | const fakeEvent = new DotnetUninstallAllStarted();
28 | loggingObserver.post(fakeEvent);
29 | loggingObserver.dispose();
30 |
31 | // Check if the log file content is same as expected content
32 | fs.readdirSync(tempPath).forEach(file =>
33 | {
34 | const logContent = fs.readFileSync(path.join(tempPath, file)).toString();
35 | assert.include(logContent, fakeEvent.eventName, 'The log file does not contain the expected content that should be written to it');
36 | });
37 |
38 | }).timeout(10000 * 2);
39 | });
40 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/src/test/unit/VersionResolver.test.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 | import * as chai from 'chai';
6 | import { IDotnetListVersionsResult } from '../../IDotnetListVersionsContext';
7 | import { LocalMemoryCacheSingleton } from '../../LocalMemoryCacheSingleton';
8 | import { WebRequestWorkerSingleton } from '../../Utils/WebRequestWorkerSingleton';
9 | import { MockVersionResolver, versionPairs } from '../mocks/MockObjects';
10 | import { getMockAcquisitionContext } from './TestUtility';
11 | const assert = chai.assert;
12 |
13 | suite('VersionResolver Unit Tests', function ()
14 | {
15 | this.afterEach(async () =>
16 | {
17 | // Tear down tmp storage for fresh run
18 | WebRequestWorkerSingleton.getInstance().destroy();
19 | LocalMemoryCacheSingleton.getInstance().invalidate();
20 | });
21 |
22 | // MockVersionResolver is a VersionResolver that uses a fake releases.json
23 | // (prevents us from making web requests in unit tests)
24 | const resolver: MockVersionResolver = new MockVersionResolver(getMockAcquisitionContext('runtime', ''));
25 |
26 | test('Get Available Versions', async () =>
27 | {
28 | const result: IDotnetListVersionsResult = await resolver.GetAvailableDotnetVersions(undefined);
29 |
30 | assert(result);
31 | assert(result.length > 0);
32 | assert(result.some(x => x.version === '2.2.207')); // this is one of the versions we'd expect to be available.
33 | });
34 |
35 | test('Error With Invalid Version', async () =>
36 | {
37 | assert.isRejected(resolver.getFullVersion('foo', 'runtime'), Error, 'Invalid version');
38 | });
39 |
40 | test('Error With Three Part Version', async () =>
41 | {
42 | assert.isRejected(resolver.getFullVersion('1.0.16', 'runtime'), Error, 'Invalid version');
43 | });
44 |
45 | test('Error With Invalid Major.Minor', async () =>
46 | {
47 | assert.isRejected(resolver.getFullVersion('0.0', 'runtime'), Error, 'Unable to resolve version');
48 | });
49 |
50 | test('Resolve Valid Runtime Versions', async () =>
51 | {
52 | for (const version of versionPairs)
53 | {
54 | assert.equal(await resolver.getFullVersion(version[0], 'runtime'), version[1]);
55 | }
56 | });
57 |
58 | test('Resolve Latest SDK Version', async () =>
59 | {
60 | assert.equal(await resolver.getFullVersion('2.2', 'sdk'), '2.2.207');
61 | });
62 | });
63 |
64 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime-library/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "outDir": "dist",
6 | "lib": [
7 | "es6"
8 | ],
9 | "skipLibCheck": true,
10 | "sourceMap": true,
11 | "declaration": true,
12 | "rootDir": "src",
13 | "strict": true /* enable all strict type-checking options */
14 | },
15 | "exclude": [
16 | "node_modules",
17 | ".vscode-test",
18 | "dist"
19 | ]
20 | }
21 |
--------------------------------------------------------------------------------
/vscode-dotnet-runtime.code-workspace:
--------------------------------------------------------------------------------
1 | {
2 | "folders": [
3 | {
4 | "path": "vscode-dotnet-runtime-extension"
5 | },
6 | {
7 | "path": "vscode-dotnet-sdk-extension"
8 | },
9 | {
10 | "path": "sample"
11 | },
12 | {
13 | "path": "vscode-dotnet-runtime-library"
14 | }
15 | ],
16 | "settings": {
17 | "cSpell.words": [
18 | "aspnetcore",
19 | "DOTNETINSTALLMODELIST",
20 | "dotnets",
21 | "Republisher",
22 | "unlocalized",
23 | "vscd"
24 | ]
25 | }
26 | }
--------------------------------------------------------------------------------
/vscode-dotnet-sdk-extension/.npmrc:
--------------------------------------------------------------------------------
1 | registry=https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/
--------------------------------------------------------------------------------
/vscode-dotnet-sdk-extension/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "0.2.0",
3 | "configurations": [{
4 | "name": "Run .NET SDK Acquisition Extension",
5 | "type": "extensionHost",
6 | "request": "launch",
7 | "runtimeExecutable": "${execPath}",
8 | "args": [
9 | "--extensionDevelopmentPath=${workspaceFolder}"
10 | ],
11 | "outFiles": [
12 | "${workspaceFolder}/dist/**/*.js"
13 | ],
14 | "preLaunchTask": "compile-all"
15 | },
16 | {
17 | "name": ".NET SDK Extension Functional Tests",
18 | "type": "extensionHost",
19 | "request": "launch",
20 | "runtimeExecutable": "${execPath}",
21 | "args": [
22 | "--extensionDevelopmentPath=${workspaceFolder}",
23 | "--extensionTestsPath=${workspaceFolder}/dist/test/functional"
24 | ],
25 | "outFiles": [
26 | "${workspaceFolder}/dist/test/**/*.js"
27 | ],
28 | "internalConsoleOptions": "openOnSessionStart",
29 | "preLaunchTask": "compile-all"
30 | }
31 | ]
32 | }
33 |
--------------------------------------------------------------------------------
/vscode-dotnet-sdk-extension/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.exclude": {
4 | "out": false // set this to true to hide the "out" folder with the compiled JS files
5 | },
6 | "search.exclude": {
7 | "out": true // set this to false to include "out" folder in search results
8 | },
9 | // Turn off tsc task auto detection since we have the necessary tasks as npm scripts
10 | "typescript.tsc.autoDetect": "off",
11 | "cSpell.words": [
12 | "APPDATA",
13 | "HKCU"
14 | ]
15 | }
--------------------------------------------------------------------------------
/vscode-dotnet-sdk-extension/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | // See https://go.microsoft.com/fwlink/?LinkId=733558
2 | // for the documentation about the tasks.json format
3 | {
4 | "version": "2.0.0",
5 | "tasks": [
6 | {
7 | "label": "compile-all",
8 | "type": "npm",
9 | "script": "compile-all",
10 | "presentation": {
11 | "reveal": "never"
12 | },
13 | "group": {
14 | "kind": "build",
15 | "isDefault": true
16 | }
17 | }
18 | ]
19 | }
20 |
--------------------------------------------------------------------------------
/vscode-dotnet-sdk-extension/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | All notable changes to this project will be documented in this file.
4 |
5 | The format is based on [Keep a Changelog],
6 | and this project adheres to [Semantic Versioning].
7 |
8 |
9 | ## [Unreleased]
10 |
11 | ### Added
12 |
13 | - A new error type for when the user tries to install via the Powershell install script on a system where powershell cannot be found [#1212]
14 | - A new error type for when an install was requested but already exists locally [#1212]
15 | - New APIs for querying SDK installations and suggested SDK versions [#791]
16 |
17 | ### Fixed
18 |
19 | - Reenable logging from this extension [#1122]
20 |
21 | ### Changed
22 |
23 | - The default timeout for downloading an Runtime archive was changed to 300 seconds from 120 seconds [#1212]. If you need longer download times, see the [timeout documentation] for more details.
24 | - The error message and pop-up for timeouts were improved to direct users how to extend the timeout [#1212]
25 |
26 | ## [0.8.0] - 2021-09-16
27 |
28 | ### Changed
29 |
30 | - Reduce the permissions required to exceute the scripts [#16120]
31 |
32 |
33 | [keep a changelog]: https://keepachangelog.com/en/1.0.0/
34 | [semantic versioning]: https://semver.org/spec/v2.0.0.html
35 | [timeout documentation]: https://github.com/dotnet/vscode-dotnet-runtime/blob/main/Documentation/troubleshooting-runtime.md#install-script-timeouts
36 |
37 |
38 | [#1122]: https://github.com/dotnet/vscode-dotnet-runtime/pull/1122
39 | [#1212]: https://github.com/dotnet/vscode-dotnet-runtime/pull/1212
40 | [#791]: https://github.com/dotnet/vscode-dotnet-runtime/pull/791
41 | [#16120]: https://github.com/dotnet/vscode-dotnet-runtime/commit/0b6504a157525b0107a68b4a2a2914782e389456
42 |
43 |
44 | [Unreleased]: https://github.com/dotnet/vscode-dotnet-runtime/compare/SDK-v0.8.0...HEAD
45 | [0.8.0]: https://github.com/dotnet/vscode-dotnet-runtime/releases/tag/SDK-v0.8.0
--------------------------------------------------------------------------------
/vscode-dotnet-sdk-extension/README.md:
--------------------------------------------------------------------------------
1 | # .NET SDK Install Tool
2 |
3 | [](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.vscode-dotnet-sdk) [](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.vscode-dotnet-sdk)
4 |
5 | This VSCode extension allows acquisition of a local copy of the .NET SDK. While originally developed and intended to be used as part of the [.NET Coding Pack], this extension can be used by other extensions like C# DevKit, Polyglot Notebooks, and others to ensure that a .NET SDK is available on the user's machine. This can be useful when another extension needs to make use of the .NET Toolchain to compile or run code.
6 |
7 | > **Note:**
8 | > .NET SDKs installed with this extension are unique *per-calling-extension*, and will not be installed system-wide. This means they will not be usable from outside of the VS Code editor.
9 |
10 | ## .NET Foundation
11 |
12 | .NET for VSCode is a [.NET Foundation](https://www.dotnetfoundation.org/projects) project.
13 |
14 | See the [.NET home repo](https://github.com/Microsoft/dotnet) to find other .NET-related projects.
15 |
16 | ## License
17 |
18 | .NET Core (including this repo) is licensed under the MIT license.
19 |
20 | ## Telemetry Notice
21 |
22 | Please note that this extension collects telemetry by default and aims to follow the [VS Code Telemetry Policy](https://code.visualstudio.com/api/extension-guides/telemetry). You may disable this telemetry in the extension settings.
23 |
24 | [.NET Coding Pack]: https://learn.microsoft.com/shows/on-net/get-started-quick-with-the-net-coding-pack
--------------------------------------------------------------------------------
/vscode-dotnet-sdk-extension/images/dotnetIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet/vscode-dotnet-runtime/9d40cb68b5a08530b000b70b0ff02ec2067d851a/vscode-dotnet-sdk-extension/images/dotnetIcon.png
--------------------------------------------------------------------------------
/vscode-dotnet-sdk-extension/src/DotnetCoreAcquisitionId.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | export const dotnetCoreAcquisitionExtensionId = 'ms-dotnettools.vscode-dotnet-sdk';
7 |
--------------------------------------------------------------------------------
/vscode-dotnet-sdk-extension/src/ExtensionUninstall.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 | import * as fs from 'fs';
6 | import * as os from 'os';
7 | import * as path from 'path';
8 | import rimraf = require('rimraf');
9 |
10 | export function uninstallSDKExtension() {
11 | const installFolderName = process.env._VSCODE_DOTNET_INSTALL_FOLDER || '.dotnet';
12 | let installPath: string;
13 | if (os.platform() === 'win32' && process.env.APPDATA) {
14 | installPath = path.join(process.env.APPDATA, installFolderName);
15 | } else if (os.platform() !== 'win32') {
16 | installPath = path.join(os.homedir(), '.vscode-dotnet-sdk');
17 | } else {
18 | return;
19 | }
20 |
21 | if (fs.existsSync(installPath)) {
22 | rimraf.sync(installPath);
23 | }
24 | }
25 |
26 | uninstallSDKExtension();
27 |
--------------------------------------------------------------------------------
/vscode-dotnet-sdk-extension/src/test/functional/index.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 | import * as glob from 'glob';
6 | import * as Mocha from 'mocha';
7 | import * as path from 'path';
8 | import * as sourceMapSupport from 'source-map-support';
9 |
10 | export function run(): Promise {
11 | sourceMapSupport.install();
12 | // Create the mocha test
13 | const mocha = new Mocha({
14 | ui: 'tdd',
15 | color: true,
16 | });
17 |
18 | const testsRoot = path.resolve(__dirname, '..');
19 |
20 | return new Promise((c, e) => {
21 | glob('**/functional/**.test.js', { cwd: testsRoot }, (err, files) => {
22 | if (err) {
23 | return e(err);
24 | }
25 |
26 | // Add files to the test suite
27 | files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
28 |
29 | try {
30 | // Run the mocha test
31 | mocha.run(failures => {
32 | if (failures > 0) {
33 | e(new Error(`${failures} tests failed.`));
34 | } else {
35 | c();
36 | }
37 | });
38 | } catch (err) {
39 | e(err);
40 | }
41 | });
42 | });
43 | }
44 |
--------------------------------------------------------------------------------
/vscode-dotnet-sdk-extension/src/test/functional/runTest.ts:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------------------
2 | * Licensed to the .NET Foundation under one or more agreements.
3 | * The .NET Foundation licenses this file to you under the MIT license.
4 | *--------------------------------------------------------------------------------------------*/
5 |
6 | import * as path from 'path';
7 | import * as os from 'os';
8 |
9 | import { runTests } from '@vscode/test-electron';
10 |
11 | async function main() {
12 | try {
13 | // The folder containing the Extension Manifest package.json
14 | // Passed to `--extensionDevelopmentPath`
15 | const extensionDevelopmentPath = path.resolve(__dirname, '../../../');
16 |
17 | // The path to the extension test runner script
18 | // Passed to --extensionTestsPath
19 | const extensionTestsPath = path.resolve(__dirname, './index');
20 | let platformValue = '';
21 | switch(os.platform())
22 | {
23 | case 'win32':
24 | platformValue = 'win32-x64-archive';
25 | break;
26 | case 'darwin':
27 | platformValue = 'darwin';
28 | break;
29 | case 'linux':
30 | platformValue = 'linux-x64';
31 | break;
32 | }
33 |
34 | // Download VS Code, unzip it and run the integration test
35 | await runTests({
36 | ...(platformValue !== '' && {platform: platformValue}),
37 | extensionDevelopmentPath,
38 | extensionTestsPath,
39 | launchArgs: [
40 | // This disables all extensions except the one being testing
41 | '--disable-extensions',
42 | ]});
43 | } catch (err) {
44 | console.error('Failed to run tests');
45 | process.exit(1);
46 | }
47 | }
48 |
49 | main();
50 |
--------------------------------------------------------------------------------
/vscode-dotnet-sdk-extension/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "outDir": "dist",
6 | "lib": [
7 | "es6"
8 | ],
9 | "sourceMap": true,
10 | "rootDir": "src",
11 | "declaration": true,
12 | "strict": true /* enable all strict type-checking options */
13 | },
14 | "exclude": [
15 | "node_modules",
16 | ".vscode-test",
17 | "dist"
18 | ]
19 | }
20 |
--------------------------------------------------------------------------------
/vscode-dotnet-sdk-extension/webpack.config.js:
--------------------------------------------------------------------------------
1 | //@ts-check
2 |
3 | 'use strict';
4 |
5 | const path = require('path');
6 | const CopyPlugin = require('copy-webpack-plugin');
7 |
8 | /**@type {import('webpack').Configuration}*/
9 | const extensionConfig = {
10 | target: 'node', // vscode extensions run in a Node.js-context 📖 -> https://webpack.js.org/configuration/node/
11 |
12 | entry: './/src/extension.ts', // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/
13 | output: {
14 | // the bundle is stored in the 'dist' folder (check package.json), 📖 -> https://webpack.js.org/configuration/output/
15 | path: path.resolve(__dirname, 'dist'),
16 | filename: 'extension.js',
17 | libraryTarget: 'commonjs2',
18 | devtoolModuleFilenameTemplate: '../[resource-path]'
19 | },
20 | node: {
21 | __dirname: false,
22 | __filename: false,
23 | },
24 | devtool: 'source-map',
25 | externals: {
26 | vscode: 'commonjs vscode' // the vscode-module is created on-the-fly and must be excluded. Add other modules that cannot be webpack'ed, 📖 -> https://webpack.js.org/configuration/externals/
27 | },
28 | resolve: {
29 | // support reading TypeScript and JavaScript files, 📖 -> https://github.com/TypeStrong/ts-loader
30 | extensions: ['.ts', '.js']
31 | },
32 | module: {
33 | rules: [
34 | {
35 | test: /\.ts$/,
36 | exclude: /node_modules/,
37 | use: [
38 | {
39 | loader: 'ts-loader'
40 | }
41 | ]
42 | }
43 | ]
44 | },
45 | plugins: [
46 | new CopyPlugin({ patterns: [
47 | { from: path.resolve(__dirname, '../vscode-dotnet-runtime-library/install scripts'), to: path.resolve(__dirname, 'dist', 'install scripts') },
48 | { from: path.resolve(__dirname, '../vscode-dotnet-runtime-library/distro-data'), to: path.resolve(__dirname, 'dist', 'distro-data') },
49 | { from: path.resolve(__dirname, '../images'), to: path.resolve(__dirname, 'images') },
50 | { from: path.resolve(__dirname, '../LICENSE.txt'), to: path.resolve(__dirname, 'LICENSE.txt') }
51 | ]}),
52 | ]
53 | };
54 | const uninstallConfig = {
55 | entry: './src/ExtensionUninstall.ts',
56 | module: {
57 | rules: [
58 | {
59 | test: /\.tsx?$/,
60 | use: 'ts-loader',
61 | exclude: /node_modules/,
62 | },
63 | ],
64 | },
65 | resolve: {
66 | extensions: ['.ts', '.js'],
67 | },
68 | output: {
69 | filename: 'ExtensionUninstall.js',
70 | path: path.resolve(__dirname, 'dist'),
71 | },
72 | target: 'node',
73 | };
74 | module.exports = [
75 | extensionConfig,
76 | uninstallConfig
77 | ];
--------------------------------------------------------------------------------