├── README.md
├── LICENSE
├── src
└── RiderLauncher
│ ├── Program.cs
│ ├── RiderLauncher.csproj
│ └── ToolboxRiderFinder.cs
├── RiderLauncher.sln
└── .gitignore
/README.md:
--------------------------------------------------------------------------------
1 | # dotnet-rider-cli
2 |
3 | This is a simple .NET Global tool to launch JetBrains Rider from the CLI on Windows.
4 |
5 | ## Installation
6 |
7 | Windows-only for now:
8 |
9 | ```shell
10 | λ dotnet tool install -g dotnet-rider-cli
11 | ```
12 |
13 | ## Usage
14 |
15 | To open the current directory:
16 | ```shell
17 | λ rider .
18 | ```
19 | To open a solution:
20 | ```shell
21 | λ rider Thing.sln
22 | ```
23 |
24 | ## Why?
25 |
26 | I install Rider using the JetBrains toolbox, and I generally
27 | use the Nightly builds, so the install location changes
28 | a lot. I don't want to keep updating an alias, so I made this.
29 | It finds all the installations of Rider under
30 | `%LOCALAPPDATA%\JetBrains\Toolbox\apps\Rider` and runs
31 | the most recent version it finds.
32 |
33 | Hope somebody else finds it useful.
34 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 RendleLabs
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/RiderLauncher/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Linq;
4 | using System.Text.RegularExpressions;
5 |
6 | namespace RiderLauncher
7 | {
8 | class Program
9 | {
10 | private const string IfThisMakesYouSad = "If this makes you sad, please open an issue at https://github.com/RendleLabs/dotnet-rider-cli";
11 |
12 | static void Main(string[] args)
13 | {
14 | if (ToolboxRiderFinder.TryGetLatestActiveExecutable(out var activeExecutable))
15 | {
16 | StartRider(activeExecutable, args);
17 | }
18 | else
19 | {
20 | Console.WriteLine($"Couldn't find Rider install location. {IfThisMakesYouSad}");
21 | }
22 | }
23 |
24 | private static void StartRider(string riderExe, string[] args)
25 | {
26 | var arguments = string.Join(" ", args.Select(a => a.Contains(' ') ? $"\"{a}\"" : a));
27 |
28 | Console.WriteLine($"Starting: {riderExe} {arguments}");
29 |
30 | var psi = new ProcessStartInfo
31 | {
32 | UseShellExecute = true,
33 | FileName = riderExe,
34 | Arguments = arguments
35 | };
36 |
37 | Process.Start(psi);
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/src/RiderLauncher/RiderLauncher.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp2.1
6 | latest
7 | true
8 | 1.0.5
9 | dotnet-rider
10 | true
11 | ..\..\artifacts\$(Configuration)
12 | dotnet-rider-cli
13 | Global dotnet tool for launching Toolbox Rider from the command line.
14 | false
15 | Initial version
16 | Copyright (C) 2018 RendleLabs
17 | jetbrains rider
18 | https://github.com/rendlelabs/dotnet-rider-cli
19 | https://github.com/RendleLabs/dotnet-rider-cli/blob/master/LICENSE
20 | https://github.com/rendlelabs/dotnet-rider-cli
21 | True
22 | rider
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/RiderLauncher.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.26124.0
5 | MinimumVisualStudioVersion = 15.0.26124.0
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{F03B2235-2DBC-48BF-A656-B24E69AD3498}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RiderLauncher", "src\RiderLauncher\RiderLauncher.csproj", "{287EBCCF-36F2-4B8B-B23E-5EF7F26F57CF}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Debug|x64 = Debug|x64
14 | Debug|x86 = Debug|x86
15 | Release|Any CPU = Release|Any CPU
16 | Release|x64 = Release|x64
17 | Release|x86 = Release|x86
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
23 | {287EBCCF-36F2-4B8B-B23E-5EF7F26F57CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24 | {287EBCCF-36F2-4B8B-B23E-5EF7F26F57CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
25 | {287EBCCF-36F2-4B8B-B23E-5EF7F26F57CF}.Debug|x64.ActiveCfg = Debug|Any CPU
26 | {287EBCCF-36F2-4B8B-B23E-5EF7F26F57CF}.Debug|x64.Build.0 = Debug|Any CPU
27 | {287EBCCF-36F2-4B8B-B23E-5EF7F26F57CF}.Debug|x86.ActiveCfg = Debug|Any CPU
28 | {287EBCCF-36F2-4B8B-B23E-5EF7F26F57CF}.Debug|x86.Build.0 = Debug|Any CPU
29 | {287EBCCF-36F2-4B8B-B23E-5EF7F26F57CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
30 | {287EBCCF-36F2-4B8B-B23E-5EF7F26F57CF}.Release|Any CPU.Build.0 = Release|Any CPU
31 | {287EBCCF-36F2-4B8B-B23E-5EF7F26F57CF}.Release|x64.ActiveCfg = Release|Any CPU
32 | {287EBCCF-36F2-4B8B-B23E-5EF7F26F57CF}.Release|x64.Build.0 = Release|Any CPU
33 | {287EBCCF-36F2-4B8B-B23E-5EF7F26F57CF}.Release|x86.ActiveCfg = Release|Any CPU
34 | {287EBCCF-36F2-4B8B-B23E-5EF7F26F57CF}.Release|x86.Build.0 = Release|Any CPU
35 | EndGlobalSection
36 | GlobalSection(NestedProjects) = preSolution
37 | {287EBCCF-36F2-4B8B-B23E-5EF7F26F57CF} = {F03B2235-2DBC-48BF-A656-B24E69AD3498}
38 | EndGlobalSection
39 | EndGlobal
40 |
--------------------------------------------------------------------------------
/src/RiderLauncher/ToolboxRiderFinder.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Runtime.InteropServices;
6 | using System.Text.RegularExpressions;
7 | using Newtonsoft.Json;
8 | using Newtonsoft.Json.Linq;
9 |
10 | namespace RiderLauncher
11 | {
12 | internal static class ToolboxRiderFinder
13 | {
14 | private static readonly Version MaxVersion = new Version(32767, 32767, 32767);
15 | private static readonly Regex VersionNumberExtractor = new Regex(@"[0-9]+\.[0-9]+\.[0-9]+");
16 |
17 | public static bool TryGetLatestActiveExecutable(out string path)
18 | {
19 | path = GetActiveExecutables()
20 | .OrderByDescending(f => Version.TryParse(VersionNumberExtractor.Match(f).Value, out var version) ? version : MaxVersion)
21 | .FirstOrDefault();
22 | return path != null;
23 | }
24 |
25 | private static IEnumerable GetActiveExecutables()
26 | {
27 | var appLocation = GetAppLocation();
28 |
29 | if (string.IsNullOrWhiteSpace(appLocation)) yield break;
30 |
31 | foreach (var channelSettingsFile in Directory.EnumerateFiles(appLocation, ".channel.settings.json", SearchOption.AllDirectories))
32 | {
33 | JObject settings;
34 | using (var reader = File.OpenText(channelSettingsFile))
35 | {
36 | using (var jsonReader = new JsonTextReader(reader))
37 | {
38 | settings = JObject.Load(jsonReader);
39 | }
40 | }
41 |
42 | var channelDirectory = Path.GetDirectoryName(channelSettingsFile);
43 | if (settings["active-application"] is JObject activeApp && activeApp["builds"] is JArray buildArray)
44 | {
45 | foreach (string build in buildArray.Values())
46 | {
47 | var riderPath = Path.Combine(channelDirectory, build, "bin", "rider64.exe");
48 | if (File.Exists(riderPath))
49 | {
50 | yield return riderPath;
51 | }
52 | }
53 | }
54 | }
55 | }
56 |
57 | private static string GetAppLocation()
58 | {
59 | var toolboxPath = GetToolboxPath();
60 |
61 | var settingsPath = Path.Combine(toolboxPath, ".settings.json");
62 |
63 | if (File.Exists(settingsPath))
64 | {
65 | JObject settings;
66 | using (var reader = File.OpenText(settingsPath))
67 | {
68 | using (var jsonReader = new JsonTextReader(reader))
69 | {
70 | settings = JObject.Load(jsonReader);
71 | }
72 | }
73 |
74 | if (settings.ContainsKey("install_location"))
75 | {
76 | var toolboxInstallLocation = settings["install_location"].Value();
77 | if (!string.IsNullOrWhiteSpace(toolboxInstallLocation))
78 | {
79 | return NullIfNotExists(Path.Combine(toolboxInstallLocation, "apps", "Rider"));
80 | }
81 | }
82 | }
83 |
84 | return NullIfNotExists(Path.Combine(toolboxPath, "apps", "Rider"));
85 | }
86 |
87 | private static string NullIfNotExists(string path) => (!string.IsNullOrWhiteSpace(path)) && Directory.Exists(path) ? path : null;
88 |
89 | private static string GetToolboxPath()
90 | {
91 | if (OperatingSystem.IsWindows())
92 | return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"JetBrains\Toolbox");
93 | if (OperatingSystem.IsLinux())
94 | return Path.Combine(Environment.GetEnvironmentVariable("HOME"), ".local/share/JetBrains/Toolbox");
95 | if (OperatingSystem.IsMacOS())
96 | return Path.Combine(Environment.GetEnvironmentVariable("HOME"), "Library/Application Support/JetBrains/Toolbox");
97 | return null;
98 | }
99 | }
100 |
101 | public static class OperatingSystem
102 | {
103 | public static bool IsWindows() =>
104 | RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
105 |
106 | public static bool IsMacOS() =>
107 | RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
108 |
109 | public static bool IsLinux() =>
110 | RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
111 | }
112 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.suo
8 | *.user
9 | *.userosscache
10 | *.sln.docstates
11 |
12 | # User-specific files (MonoDevelop/Xamarin Studio)
13 | *.userprefs
14 |
15 | # Build results
16 | [Dd]ebug/
17 | [Dd]ebugPublic/
18 | [Rr]elease/
19 | [Rr]eleases/
20 | x64/
21 | x86/
22 | bld/
23 | [Bb]in/
24 | [Oo]bj/
25 | [Ll]og/
26 |
27 | # Visual Studio 2015/2017 cache/options directory
28 | .vs/
29 | # Uncomment if you have tasks that create the project's static files in wwwroot
30 | #wwwroot/
31 |
32 | # Visual Studio 2017 auto generated files
33 | Generated\ Files/
34 |
35 | # MSTest test Results
36 | [Tt]est[Rr]esult*/
37 | [Bb]uild[Ll]og.*
38 |
39 | # NUNIT
40 | *.VisualState.xml
41 | TestResult.xml
42 |
43 | # Build Results of an ATL Project
44 | [Dd]ebugPS/
45 | [Rr]eleasePS/
46 | dlldata.c
47 |
48 | # Benchmark Results
49 | BenchmarkDotNet.Artifacts/
50 |
51 | # .NET Core
52 | project.lock.json
53 | project.fragment.lock.json
54 | artifacts/
55 | **/Properties/launchSettings.json
56 |
57 | # StyleCop
58 | StyleCopReport.xml
59 |
60 | # Files built by Visual Studio
61 | *_i.c
62 | *_p.c
63 | *_i.h
64 | *.ilk
65 | *.meta
66 | *.obj
67 | *.iobj
68 | *.pch
69 | *.pdb
70 | *.ipdb
71 | *.pgc
72 | *.pgd
73 | *.rsp
74 | *.sbr
75 | *.tlb
76 | *.tli
77 | *.tlh
78 | *.tmp
79 | *.tmp_proj
80 | *.log
81 | *.vspscc
82 | *.vssscc
83 | .builds
84 | *.pidb
85 | *.svclog
86 | *.scc
87 |
88 | # Chutzpah Test files
89 | _Chutzpah*
90 |
91 | # Visual C++ cache files
92 | ipch/
93 | *.aps
94 | *.ncb
95 | *.opendb
96 | *.opensdf
97 | *.sdf
98 | *.cachefile
99 | *.VC.db
100 | *.VC.VC.opendb
101 |
102 | # Visual Studio profiler
103 | *.psess
104 | *.vsp
105 | *.vspx
106 | *.sap
107 |
108 | # Visual Studio Trace Files
109 | *.e2e
110 |
111 | # TFS 2012 Local Workspace
112 | $tf/
113 |
114 | # Guidance Automation Toolkit
115 | *.gpState
116 |
117 | # ReSharper is a .NET coding add-in
118 | _ReSharper*/
119 | *.[Rr]e[Ss]harper
120 | *.DotSettings.user
121 |
122 | # JustCode is a .NET coding add-in
123 | .JustCode
124 |
125 | # TeamCity is a build add-in
126 | _TeamCity*
127 |
128 | # DotCover is a Code Coverage Tool
129 | *.dotCover
130 |
131 | # AxoCover is a Code Coverage Tool
132 | .axoCover/*
133 | !.axoCover/settings.json
134 |
135 | # Visual Studio code coverage results
136 | *.coverage
137 | *.coveragexml
138 |
139 | # NCrunch
140 | _NCrunch_*
141 | .*crunch*.local.xml
142 | nCrunchTemp_*
143 |
144 | # MightyMoose
145 | *.mm.*
146 | AutoTest.Net/
147 |
148 | # Web workbench (sass)
149 | .sass-cache/
150 |
151 | # Installshield output folder
152 | [Ee]xpress/
153 |
154 | # DocProject is a documentation generator add-in
155 | DocProject/buildhelp/
156 | DocProject/Help/*.HxT
157 | DocProject/Help/*.HxC
158 | DocProject/Help/*.hhc
159 | DocProject/Help/*.hhk
160 | DocProject/Help/*.hhp
161 | DocProject/Help/Html2
162 | DocProject/Help/html
163 |
164 | # Click-Once directory
165 | publish/
166 |
167 | # Publish Web Output
168 | *.[Pp]ublish.xml
169 | *.azurePubxml
170 | # Note: Comment the next line if you want to checkin your web deploy settings,
171 | # but database connection strings (with potential passwords) will be unencrypted
172 | *.pubxml
173 | *.publishproj
174 |
175 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
176 | # checkin your Azure Web App publish settings, but sensitive information contained
177 | # in these scripts will be unencrypted
178 | PublishScripts/
179 |
180 | # NuGet Packages
181 | *.nupkg
182 | # The packages folder can be ignored because of Package Restore
183 | **/[Pp]ackages/*
184 | # except build/, which is used as an MSBuild target.
185 | !**/[Pp]ackages/build/
186 | # Uncomment if necessary however generally it will be regenerated when needed
187 | #!**/[Pp]ackages/repositories.config
188 | # NuGet v3's project.json files produces more ignorable files
189 | *.nuget.props
190 | *.nuget.targets
191 |
192 | # Microsoft Azure Build Output
193 | csx/
194 | *.build.csdef
195 |
196 | # Microsoft Azure Emulator
197 | ecf/
198 | rcf/
199 |
200 | # Windows Store app package directories and files
201 | AppPackages/
202 | BundleArtifacts/
203 | Package.StoreAssociation.xml
204 | _pkginfo.txt
205 | *.appx
206 |
207 | # Visual Studio cache files
208 | # files ending in .cache can be ignored
209 | *.[Cc]ache
210 | # but keep track of directories ending in .cache
211 | !*.[Cc]ache/
212 |
213 | # Others
214 | ClientBin/
215 | ~$*
216 | *~
217 | *.dbmdl
218 | *.dbproj.schemaview
219 | *.jfm
220 | *.pfx
221 | *.publishsettings
222 | orleans.codegen.cs
223 |
224 | # Including strong name files can present a security risk
225 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
226 | #*.snk
227 |
228 | # Since there are multiple workflows, uncomment next line to ignore bower_components
229 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
230 | #bower_components/
231 |
232 | # RIA/Silverlight projects
233 | Generated_Code/
234 |
235 | # Backup & report files from converting an old project file
236 | # to a newer Visual Studio version. Backup files are not needed,
237 | # because we have git ;-)
238 | _UpgradeReport_Files/
239 | Backup*/
240 | UpgradeLog*.XML
241 | UpgradeLog*.htm
242 | ServiceFabricBackup/
243 | *.rptproj.bak
244 |
245 | # SQL Server files
246 | *.mdf
247 | *.ldf
248 | *.ndf
249 |
250 | # Business Intelligence projects
251 | *.rdl.data
252 | *.bim.layout
253 | *.bim_*.settings
254 | *.rptproj.rsuser
255 |
256 | # Microsoft Fakes
257 | FakesAssemblies/
258 |
259 | # GhostDoc plugin setting file
260 | *.GhostDoc.xml
261 |
262 | # Node.js Tools for Visual Studio
263 | .ntvs_analysis.dat
264 | node_modules/
265 |
266 | # Visual Studio 6 build log
267 | *.plg
268 |
269 | # Visual Studio 6 workspace options file
270 | *.opt
271 |
272 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
273 | *.vbw
274 |
275 | # Visual Studio LightSwitch build output
276 | **/*.HTMLClient/GeneratedArtifacts
277 | **/*.DesktopClient/GeneratedArtifacts
278 | **/*.DesktopClient/ModelManifest.xml
279 | **/*.Server/GeneratedArtifacts
280 | **/*.Server/ModelManifest.xml
281 | _Pvt_Extensions
282 |
283 | # Paket dependency manager
284 | .paket/paket.exe
285 | paket-files/
286 |
287 | # FAKE - F# Make
288 | .fake/
289 |
290 | # JetBrains Rider
291 | .idea/
292 | *.sln.iml
293 |
294 | # CodeRush
295 | .cr/
296 |
297 | # Python Tools for Visual Studio (PTVS)
298 | __pycache__/
299 | *.pyc
300 |
301 | # Cake - Uncomment if you are using it
302 | # tools/**
303 | # !tools/packages.config
304 |
305 | # Tabs Studio
306 | *.tss
307 |
308 | # Telerik's JustMock configuration file
309 | *.jmconfig
310 |
311 | # BizTalk build output
312 | *.btp.cs
313 | *.btm.cs
314 | *.odx.cs
315 | *.xsd.cs
316 |
317 | # OpenCover UI analysis results
318 | OpenCover/
319 |
320 | # Azure Stream Analytics local run output
321 | ASALocalRun/
322 |
323 | # MSBuild Binary and Structured Log
324 | *.binlog
325 |
326 | # NVidia Nsight GPU debugger configuration file
327 | *.nvuser
328 |
329 | # MFractors (Xamarin productivity tool) working folder
330 | .mfractor/
331 |
--------------------------------------------------------------------------------