There is no super convenient way, but let me describe how we solved this in my previous team.
First of all, we have one Git repo (let's call it CodeStyle
) containing all settings that shall be shared:
CreateSymbolicLinkForEditorconfig.ps1
MyCompany.DotSettings
.editorconfig
ReSpeller/de.aff
ReSpeller/de.dic
Every developer will clone this repo, e.g. into C:\source\CodeStyle
.
Now we have different apps, all living in their repository:
They will be cloned beside the settings repo into C:\source
, giving us the following structure:
C:\source\MyApp1
C:\source\MyApp2
R# settings files allow you to reference other settings files via a relative path. A repo-specific R# settings C:\source\MyApp1\MyApp1.sln.DotSettings
might look like this:
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/Environment/InjectedLayers/FileInjectedLayer/=15C315CEAAF9FC4EA4785B81F2986594/AbsolutePath/@EntryValue">..\Codestyle\MyCompany.DotSettings</s:String>
<s:String x:Key="/Default/Environment/InjectedLayers/FileInjectedLayer/=15C315CEAAF9FC4EA4785B81F2986594/RelativePath/@EntryValue">..\Codestyle\MyCompany.DotSettings</s:String>
<s:Boolean x:Key="/Default/Environment/InjectedLayers/FileInjectedLayer/=15C315CEAAF9FC4EA4785B81F2986594/@KeyIndexDefined">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/InjectedLayers/InjectedLayerCustomization/=File15C315CEAAF9FC4EA4785B81F2986594/@KeyIndexDefined">True</s:Boolean>
<s:Double x:Key="/Default/Environment/InjectedLayers/InjectedLayerCustomization/=File15C315CEAAF9FC4EA4785B81F2986594/RelativePriority/@EntryValue">1</s:Double>
As you can see, the repo-specific R# config C:\source\MyApp1\MyApp1.sln.DotSettings
references the shared MyCompany.DotSettings
from the other repo.
The only caveat is that you make certain assumptions and implicit requirements for the directory structure (e.g. renaming the cloned codestyle directory from C:\source\CodeStyle
to C:\source\CodeStyleSettings
locally) will break this approach. However, we preferred having a shared R# settings file; therefore, this compromise was okay for us.
Another approach would be to use a Git submodule - this frees you from the previously described problem of a directory structure that is implicitly set in stone.
You might wonder what the file CreateSymbolicLinkForEditorconfig.ps1
is about. Since .editorconfig
allows directory-based inheritance (i.e C:\source\.editorconfig
will automatically be applied to all directories in C:\source
), we somehow needed to "move" the file C:\source\CodeStyle\.editorconfig
one directory up to C:\source\.editorconfig
so that all other repos can pick it up.
For the sake of simplicity, we create a symbolic link with the PowerShell script CreateSymbolicLinkForEditorconfig.ps1
:
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
Write-Host "Running elevated..."
$arguments = "& '" + $myinvocation.mycommand.definition + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
}
$sourceFile = "$PSScriptRoot\.editorconfig"
$destinationLink = "$PSScriptRoot\..\.editorconfig"
if (Test-Path -Path $destinationLink) {
Write-Host "File '$destinationLink' already exists"
}
else {
New-Item -ItemType SymbolicLink -Path $destinationLink -Value $sourceFile
Write-Host "Created Symbolic Link '$destinationLink' pointing to '$sourceFile'"
}
Hope this helps!