JetBrains / JetBrains/resharper-unity
Can't use sln.DotSettings properly (team layer settings)
- Dominant language
- C#
- Stars
- 1.2k
- Forks
- 142
- PR merge metrics
- No merged PRs in 30d
Description
Since Unity generated solution is based of on the project directory name, putting a versioned .sln.DotSettings file at root isn't guaranteed that users will have the same solution file name.
This may be related to #568 since the only way to set a naming rule is at .DotSettings file (.editorconfig naming aren't picked by Rider)
My workaround was to version a .DotSettings and after solution generation by unity, create a symbolic link with the correct name pointing to it, Rider seems to pick it up nicely.
```
using System;
using System.IO;
using System.Diagnostics;
using JetBrains.Rider.Unity.Editor;
using UnityEngine;
using UnityEditor;
using Debug = UnityEngine.Debug;
public class SolutionPostProcess : AssetPostprocessor
{
public override int GetPostprocessOrder()
{
return 20;
}
static readonly string DotSettingsFilename = ".DotSettings";
public static void OnGeneratedCSProjectFiles()
{
if (!PluginEntryPoint.Enabled) { return; }
if (!File.Exists(DotSettingsFilename)) { return; }
// TODO: Windows support (mklink)
if (Application.platform != RuntimePlatform.OSXEditor) { return; }
try
{
var projectDirectory = Path.GetDirectoryName(Application.dataPath);
var projectName = Path.GetFileName(projectDirectory);
var slnFile = Path.GetFullPath(projectName + ".sln");
var slnDotSettingsFile = slnFile + DotSettingsFilename;
if (!File.Exists(slnFile)) { return; }
if (File.Exists(slnDotSettingsFile)) { return; }
var ret = RunCommandLine("ln", "-s " + DotSettingsFilename + " " + slnDotSettingsFile);
if (ret != 0) { Debug.LogWarning("Failed to link .DotSettings"); }
}
catch (Exception e)
{
Debug.LogException(e);
}
}
static int RunCommandLine(string command, string args)
{
var startInfo = new ProcessStartInfo(command, args);
using (var process = Process.Start(startInfo))
{
if (process == null) { return -1; }
process.WaitForExit();
return process.ExitCode;
}
}
}
```
I'm not sure if there's a better way to handle team-shared (thus versioned) code settings.
Contributor guide
Assessment
This issue has not been assessed yet.