Skip to content

Commit e8cd069

Browse files
authored
Merge pull request #247 from kriszek/configurable-tools-directory
Configuration option for app data folder
2 parents 936aadf + 009f16b commit e8cd069

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ but there may be a preview version that you want to use. This can be configured
3131
Configuration is available with Visual Studio settings and project msbuild properties. All visual studio settings can be overridden from test project settings and some settings
3232
can only be set in project files.
3333

34+
The coverage tools that FCC leverages are by default installed into the FineCodeCoverage directory within `Environment.SpecialFolder.LocalApplicationData`.
35+
This can be changed with the ToolsDirectory Visual Studio option. Ensure that this containing directory exists and upon restart the tools will be installed within.
36+
3437
---
3538

3639
### <a href="https://www.youtube.com/watch?v=Rae5bTE2D3o" target="_blank">Watch Introduction Video</a>
@@ -146,6 +149,8 @@ CoverletConsoleGlobal Specify true to use your own dotnet tools global inst
146149
FCCSolutionOutputDirectoryName To have fcc output visible in a sub folder of your solution provide this name
147150
AdjacentBuildOutput If your tests are dependent upon their path set this to true.
148151
152+
ToolsDirectory Folder to which copy tools subfolder. Must alredy exist. Requires restart of VS.
153+
149154
The "CoverletConsole" settings have precedence Local / CustomPath / Global.
150155
151156
Both 'Exclude' and 'Include' options can be used together but 'Exclude' takes precedence.

SharedProject/Core/AppDataFolder.cs

+12-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.IO;
44
using System.Linq;
55
using System.Threading;
6+
using FineCodeCoverage.Options;
67

78
namespace FineCodeCoverage.Engine
89
{
@@ -12,13 +13,15 @@ internal class AppDataFolder : IAppDataFolder
1213
{
1314
private readonly ILogger logger;
1415
private readonly IEnvironmentVariable environmentVariable;
16+
private readonly IAppOptionsProvider appOptionsProvider;
1517
internal const string fccDebugCleanInstallEnvironmentVariable = "FCCDebugCleanInstall";
1618

1719
[ImportingConstructor]
18-
public AppDataFolder(ILogger logger,IEnvironmentVariable environmentVariable)
20+
public AppDataFolder(ILogger logger,IEnvironmentVariable environmentVariable, IAppOptionsProvider appOptionsProvider)
1921
{
2022
this.logger = logger;
2123
this.environmentVariable = environmentVariable;
24+
this.appOptionsProvider = appOptionsProvider;
2225
}
2326
public string DirectoryPath { get; private set; }
2427

@@ -34,7 +37,7 @@ public void Initialize(CancellationToken camcellationToken)
3437

3538
private void CreateAppDataFolder()
3639
{
37-
DirectoryPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), Vsix.Code);
40+
DirectoryPath = Path.Combine(GetAppDataFolder(), Vsix.Code);
3841
if (environmentVariable.Get(fccDebugCleanInstallEnvironmentVariable) != null)
3942
{
4043
logger.Log("FCCDebugCleanInstall");
@@ -58,6 +61,13 @@ private void CreateAppDataFolder()
5861
Directory.CreateDirectory(DirectoryPath);
5962
}
6063

64+
private string GetAppDataFolder()
65+
{
66+
var dir = appOptionsProvider.Get().ToolsDirectory;
67+
68+
return Directory.Exists(dir) ? dir : Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
69+
}
70+
6171
private void CleanupLegacyFolders()
6272
{
6373
Directory

SharedProject/Options/AppOptions.cs

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace FineCodeCoverage.Options
99
internal class AppOptions : DialogPage, IAppOptions
1010
{
1111
private const string runCategory = "Run";
12+
private const string environmentCategory = "Environment";
1213
private const string excludeIncludeCategory = "Exclude / Include";
1314
private const string coverletCategory = "Coverlet";
1415
private const string openCoverCategory = "OpenCover";
@@ -115,6 +116,10 @@ You can also ignore additional attributes by adding to this list (short name or
115116
[Category(runCategory)]
116117
public int RunWhenTestsExceed { get; set; }
117118

119+
[Description("Folder to which copy tools subfolder. Must alredy exist. Requires restart of VS.")]
120+
[Category(environmentCategory)]
121+
public string ToolsDirectory { get; set; }
122+
118123
[Description("Specify false for global and project options to be used for coverlet data collector configuration elements when not specified in runsettings")]
119124
[Category(coverletCategory)]
120125
public bool RunSettingsOnly { get; set; } = true;

SharedProject/Options/IAppOptions.cs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public interface IAppOptions
1010
bool IncludeTestAssembly { get; }
1111
bool RunInParallel { get; }
1212
int RunWhenTestsExceed { get; }
13+
string ToolsDirectory { get; }
1314
bool RunWhenTestsFail { get; }
1415
bool RunSettingsOnly { get; }
1516
bool CoverletConsoleGlobal { get; }

0 commit comments

Comments
 (0)