Skip to content

Commit d0706be

Browse files
committed
Keep a way to disable patching
1 parent a954a5c commit d0706be

File tree

1 file changed

+73
-66
lines changed

1 file changed

+73
-66
lines changed

Packages/com.unity.ide.visualstudio/Editor/VisualStudioCodeInstallation.cs

Lines changed: 73 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,11 @@ public override void CreateExtraFiles(string projectDirectory)
196196
var vscodeDirectory = IOPath.Combine(projectDirectory.NormalizePathSeparators(), ".vscode");
197197
Directory.CreateDirectory(vscodeDirectory);
198198

199-
CreateRecommendedExtensionsFile(vscodeDirectory);
200-
CreateSettingsFile(vscodeDirectory);
201-
CreateLaunchFile(vscodeDirectory);
199+
var enablePatch = !File.Exists(IOPath.Combine(vscodeDirectory, ".vstupatchdisable"));
200+
201+
CreateRecommendedExtensionsFile(vscodeDirectory, enablePatch);
202+
CreateSettingsFile(vscodeDirectory, enablePatch);
203+
CreateLaunchFile(vscodeDirectory, enablePatch);
202204
}
203205
catch (IOException)
204206
{
@@ -216,12 +218,14 @@ public override void CreateExtraFiles(string projectDirectory)
216218
]
217219
}";
218220

219-
private static void CreateLaunchFile(string vscodeDirectory)
221+
private static void CreateLaunchFile(string vscodeDirectory, bool enablePatch)
220222
{
221223
var launchFile = IOPath.Combine(vscodeDirectory, "launch.json");
222224
if (File.Exists(launchFile))
223225
{
224-
PatchLaunchFile(launchFile);
226+
if (enablePatch)
227+
PatchLaunchFile(launchFile);
228+
225229
return;
226230
}
227231

@@ -281,72 +285,73 @@ private static void PatchLaunchFile(string launchFile)
281285
}
282286
}
283287

284-
private void CreateSettingsFile(string vscodeDirectory)
288+
private void CreateSettingsFile(string vscodeDirectory, bool enablePatch)
285289
{
286290
var settingsFile = IOPath.Combine(vscodeDirectory, "settings.json");
287291
if (File.Exists(settingsFile))
288292
{
289-
PatchSettingsFile(settingsFile);
293+
if (enablePatch)
294+
PatchSettingsFile(settingsFile);
295+
290296
return;
291297
}
292298

293-
const string excludes = @" ""files.exclude"":
294-
{
295-
""**/.DS_Store"":true,
296-
""**/.git"":true,
297-
""**/.vs"":true,
298-
""**/.gitmodules"":true,
299-
""**/.vsconfig"":true,
300-
""**/*.booproj"":true,
301-
""**/*.pidb"":true,
302-
""**/*.suo"":true,
303-
""**/*.user"":true,
304-
""**/*.userprefs"":true,
305-
""**/*.unityproj"":true,
306-
""**/*.dll"":true,
307-
""**/*.exe"":true,
308-
""**/*.pdf"":true,
309-
""**/*.mid"":true,
310-
""**/*.midi"":true,
311-
""**/*.wav"":true,
312-
""**/*.gif"":true,
313-
""**/*.ico"":true,
314-
""**/*.jpg"":true,
315-
""**/*.jpeg"":true,
316-
""**/*.png"":true,
317-
""**/*.psd"":true,
318-
""**/*.tga"":true,
319-
""**/*.tif"":true,
320-
""**/*.tiff"":true,
321-
""**/*.3ds"":true,
322-
""**/*.3DS"":true,
323-
""**/*.fbx"":true,
324-
""**/*.FBX"":true,
325-
""**/*.lxo"":true,
326-
""**/*.LXO"":true,
327-
""**/*.ma"":true,
328-
""**/*.MA"":true,
329-
""**/*.obj"":true,
330-
""**/*.OBJ"":true,
331-
""**/*.asset"":true,
332-
""**/*.cubemap"":true,
333-
""**/*.flare"":true,
334-
""**/*.mat"":true,
335-
""**/*.meta"":true,
336-
""**/*.prefab"":true,
337-
""**/*.unity"":true,
338-
""build/"":true,
339-
""Build/"":true,
340-
""Library/"":true,
341-
""library/"":true,
342-
""obj/"":true,
343-
""Obj/"":true,
344-
""Logs/"":true,
345-
""logs/"":true,
346-
""ProjectSettings/"":true,
347-
""UserSettings/"":true,
348-
""temp/"":true,
349-
""Temp/"":true
299+
const string excludes = @" ""files.exclude"": {
300+
""**/.DS_Store"": true,
301+
""**/.git"": true,
302+
""**/.vs"": true,
303+
""**/.gitmodules"": true,
304+
""**/.vsconfig"": true,
305+
""**/*.booproj"": true,
306+
""**/*.pidb"": true,
307+
""**/*.suo"": true,
308+
""**/*.user"": true,
309+
""**/*.userprefs"": true,
310+
""**/*.unityproj"": true,
311+
""**/*.dll"": true,
312+
""**/*.exe"": true,
313+
""**/*.pdf"": true,
314+
""**/*.mid"": true,
315+
""**/*.midi"": true,
316+
""**/*.wav"": true,
317+
""**/*.gif"": true,
318+
""**/*.ico"": true,
319+
""**/*.jpg"": true,
320+
""**/*.jpeg"": true,
321+
""**/*.png"": true,
322+
""**/*.psd"": true,
323+
""**/*.tga"": true,
324+
""**/*.tif"": true,
325+
""**/*.tiff"": true,
326+
""**/*.3ds"": true,
327+
""**/*.3DS"": true,
328+
""**/*.fbx"": true,
329+
""**/*.FBX"": true,
330+
""**/*.lxo"": true,
331+
""**/*.LXO"": true,
332+
""**/*.ma"": true,
333+
""**/*.MA"": true,
334+
""**/*.obj"": true,
335+
""**/*.OBJ"": true,
336+
""**/*.asset"": true,
337+
""**/*.cubemap"": true,
338+
""**/*.flare"": true,
339+
""**/*.mat"": true,
340+
""**/*.meta"": true,
341+
""**/*.prefab"": true,
342+
""**/*.unity"": true,
343+
""build/"": true,
344+
""Build/"": true,
345+
""Library/"": true,
346+
""library/"": true,
347+
""obj/"": true,
348+
""Obj/"": true,
349+
""Logs/"": true,
350+
""logs/"": true,
351+
""ProjectSettings/"": true,
352+
""UserSettings/"": true,
353+
""temp/"": true,
354+
""Temp/"": true
350355
}";
351356

352357
var content = @"{
@@ -418,13 +423,15 @@ private void PatchSettingsFile(string settingsFile)
418423
}
419424
";
420425

421-
private static void CreateRecommendedExtensionsFile(string vscodeDirectory)
426+
private static void CreateRecommendedExtensionsFile(string vscodeDirectory, bool enablePatch)
422427
{
423428
// see https://tattoocoder.com/recommending-vscode-extensions-within-your-open-source-projects/
424429
var extensionFile = IOPath.Combine(vscodeDirectory, "extensions.json");
425430
if (File.Exists(extensionFile))
426431
{
427-
PatchRecommendedExtensionsFile(extensionFile);
432+
if (enablePatch)
433+
PatchRecommendedExtensionsFile(extensionFile);
434+
428435
return;
429436
}
430437

0 commit comments

Comments
 (0)