Skip to content

Commit

Permalink
Use CPS_DiagnosticRuntime instead of PROJECTSYSTEM_PROJECTOUTPUTPANEE…
Browse files Browse the repository at this point in the history
…NABLED

This replaces PROJECTSYSTEM_PROJECTOUTPUTPANEENABLED in lieu of checking for the diagnostic runtime which is turned on by CPS_DiagnosticRuntime environment variable. This is turned on by default on F5 for CPS and this repository.
  • Loading branch information
davkean committed Jul 10, 2020
1 parent 6e350c6 commit 1c97c19
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 29 deletions.
1 change: 0 additions & 1 deletion Launch.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ set VisualStudioXamlRulesDir=%Root%\artifacts\Debug\VSSetup\Rules\
set VisualBasicDesignTimeTargetsPath=%VisualStudioXamlRulesDir%Microsoft.VisualBasic.DesignTime.targets
set FSharpDesignTimeTargetsPath=%VisualStudioXamlRulesDir%Microsoft.FSharp.DesignTime.targets
set CSharpDesignTimeTargetsPath=%VisualStudioXamlRulesDir%Microsoft.CSharp.DesignTime.targets
set PROJECTSYSTEM_PROJECTOUTPUTPANEENABLED=1
set CPS_DiagnosticRuntime=1
set CPS_MetricsCollection=1

Expand Down
8 changes: 7 additions & 1 deletion docs/repo/debugging/logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,23 @@ while debugging or when a certain environment variable is set.

## Enabling project system logs

### 16.7 or earlier
Setting the `PROJECTSYSTEM_PROJECTOUTPUTPANEENABLED` environment variable to
`1` enables project system logging.

### 16.8 or later
Setting the `CPS_DiagnosticRuntime` environment variable to
`1` enables project system logging.


This environment variable is set automatically when launching the
`ProjectSystemSetup` project within Visual Studio, via its
`launchSettings.json` file.

To enable this logging in other situations you may, for example:

1. Start a Developer Command Prompt
2. Run: `set PROJECTSYSTEM_PROJECTOUTPUTPANEENABLED=1`
2. Run: `set CPS_DiagnosticRuntime=1`
3. Run: `devenv`
4. Open a solution
5. Use "View.Output Window"
Expand Down
4 changes: 0 additions & 4 deletions setup/ProjectSystemSetup/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"VisualBasicDesignTimeTargetsPath": "$(VisualStudioXamlRulesDir)Microsoft.VisualBasic.DesignTime.targets",
"FSharpDesignTimeTargetsPath": "$(VisualStudioXamlRulesDir)Microsoft.FSharp.DesignTime.targets",
"CSharpDesignTimeTargetsPath": "$(VisualStudioXamlRulesDir)Microsoft.CSharp.DesignTime.targets",
"PROJECTSYSTEM_PROJECTOUTPUTPANEENABLED": "1",
"CPS_DiagnosticRuntime": "1",
"CPS_MetricsCollection": "1"
}
Expand All @@ -21,7 +20,6 @@
"VisualBasicDesignTimeTargetsPath": "$(VisualStudioXamlRulesDir)Microsoft.VisualBasic.DesignTime.targets",
"FSharpDesignTimeTargetsPath": "$(VisualStudioXamlRulesDir)Microsoft.FSharp.DesignTime.targets",
"CSharpDesignTimeTargetsPath": "$(VisualStudioXamlRulesDir)Microsoft.CSharp.DesignTime.targets",
"PROJECTSYSTEM_PROJECTOUTPUTPANEENABLED": "1",
"CPS_DiagnosticRuntime": "1",
"CPS_MetricsCollection": "1"
},
Expand All @@ -35,7 +33,6 @@
"VisualBasicDesignTimeTargetsPath": "$(VisualStudioXamlRulesDir)Microsoft.VisualBasic.DesignTime.targets",
"FSharpDesignTimeTargetsPath": "$(VisualStudioXamlRulesDir)Microsoft.FSharp.DesignTime.targets",
"CSharpDesignTimeTargetsPath": "$(VisualStudioXamlRulesDir)Microsoft.CSharp.DesignTime.targets",
"PROJECTSYSTEM_PROJECTOUTPUTPANEENABLED": "1",
"CPS_DiagnosticRuntime": "1",
"CPS_MetricsCollection": "1",
"COMPlus_ZapDisable": "1"
Expand All @@ -50,7 +47,6 @@
"VisualBasicDesignTimeTargetsPath": "$(VisualStudioXamlRulesDir)Microsoft.VisualBasic.DesignTime.targets",
"FSharpDesignTimeTargetsPath": "$(VisualStudioXamlRulesDir)Microsoft.FSharp.DesignTime.targets",
"CSharpDesignTimeTargetsPath": "$(VisualStudioXamlRulesDir)Microsoft.CSharp.DesignTime.targets",
"PROJECTSYSTEM_PROJECTOUTPUTPANEENABLED": "1",
"CPS_DiagnosticRuntime": "1",
"CPS_MetricsCollection": "1"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE.md file in the project root for more information.

using System;
using System.ComponentModel.Composition;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.VisualStudio.ProjectSystem.Utilities;
using Microsoft.VisualStudio.Settings;
using Microsoft.VisualStudio.Threading;

Expand All @@ -15,24 +15,21 @@ internal class ProjectSystemOptions : IProjectSystemOptions
private const string FastUpToDateEnabledSettingKey = @"ManagedProjectSystem\FastUpToDateCheckEnabled";
private const string FastUpToDateLogLevelSettingKey = @"ManagedProjectSystem\FastUpToDateLogLevel";
private const string UseDesignerByDefaultSettingKey = @"ManagedProjectSystem\UseDesignerByDefault";

private readonly IEnvironmentHelper _environment;
private readonly IProjectService _projectService;
private readonly IVsUIService<ISettingsManager> _settingsManager;
private readonly JoinableTaskContext _joinableTaskContext;
private bool? _isProjectOutputPaneEnabled;
private readonly Lazy<bool> _isProjectOutputPaneEnabled;

[ImportingConstructor]
public ProjectSystemOptions(IEnvironmentHelper environment, IVsUIService<SVsSettingsPersistenceManager, ISettingsManager> settingsManager, JoinableTaskContext joinableTaskContext)
public ProjectSystemOptions(IProjectService projectService, IVsUIService<SVsSettingsPersistenceManager, ISettingsManager> settingsManager, JoinableTaskContext joinableTaskContext)
{
_environment = environment;
_projectService = projectService;
_settingsManager = settingsManager;
_joinableTaskContext = joinableTaskContext;
_isProjectOutputPaneEnabled = new Lazy<bool>(() => _projectService.Capabilities.Contains(ServiceCapability.DiagnosticRuntimeServiceCapability));
}

public bool IsProjectOutputPaneEnabled
{
get { return IsEnvironmentVariableEnabled("PROJECTSYSTEM_PROJECTOUTPUTPANEENABLED", ref _isProjectOutputPaneEnabled); }
}
public bool IsProjectOutputPaneEnabled => _isProjectOutputPaneEnabled.Value;

public Task<bool> GetIsFastUpToDateCheckEnabledAsync(CancellationToken cancellationToken = default)
{
Expand Down Expand Up @@ -67,17 +64,5 @@ private async Task SetSettingValueAsync(string name, object value, CancellationT

await _settingsManager.Value.SetValueAsync(name, value, isMachineLocal: false);
}

private bool IsEnvironmentVariableEnabled(string variable, ref bool? result)
{
if (result == null)
{
string value = _environment.GetEnvironmentVariable(variable);

result = string.Equals(value, "1", StringComparisons.EnvironmentVariables);
}

return result.Value;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.VisualStudio.ProjectSystem
/// <summary>
/// Provides properties for retrieving options for the project system.
/// </summary>
[ProjectSystemContract(ProjectSystemContractScope.Global, ProjectSystemContractProvider.Private, Cardinality = ImportCardinality.ExactlyOne)]
[ProjectSystemContract(ProjectSystemContractScope.ProjectService, ProjectSystemContractProvider.Private, Cardinality = ImportCardinality.ExactlyOne)]
internal interface IProjectSystemOptions
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE.md file in the project root for more information.

namespace Microsoft.VisualStudio.ProjectSystem
{
/// <summary>
/// Well-known <see cref="IProjectService"/> capabilities.
/// </summary>
internal static class ServiceCapability
{
/// <summary>
/// Indicates that CPS has its diagnostic runtime enabled.
/// </summary>
public const string DiagnosticRuntimeServiceCapability = "Microsoft.VisualStudio.ProjectSystem.DiagnosticRuntime";
}
}

0 comments on commit 1c97c19

Please sign in to comment.