diff --git a/Directory.Build.props b/Directory.Build.props
index 3b8b6907..f8117bd5 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -7,4 +7,11 @@
+
+ $(DefineConstants);VSIXGallery
+ $(DefineConstants);MARKETPLACE
+ $(DefineConstants);VSIX
+ $(DefineConstants);VSIX
+
+
\ No newline at end of file
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index b991e391..8e4c14ad 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -16,6 +16,18 @@ jobs:
- job: Build
pool:
vmImage: vs2017-win2016
+ strategy:
+ matrix:
+ Config_Release:
+ BuildConfiguration: Release
+ BuildOutputDirectory: Zip
+ Config_Marketplace:
+ BuildConfiguration: Marketplace
+ BuildOutputDirectory: Marketplace
+ Config_VSIXGallery:
+ BuildConfiguration: VSIXGallery
+ BuildOutputDirectory: VSIXGallery
+
steps:
- task: DotNetCoreCLI@2
inputs:
@@ -25,6 +37,9 @@ jobs:
displayName: Install NBGV tool
continueOnError: true
+ - powershell: |
+ mkdir $(Build.ArtifactStagingDirectory)\$(BuildOutputDirectory)
+
- script: nbgv cloud -a
displayName: Set Version
@@ -47,7 +62,7 @@ jobs:
- task: CopyFiles@2
inputs:
contents: '**/bin/$(BuildConfiguration)/*.vsix'
- targetFolder: $(Build.ArtifactStagingDirectory)/artifacts
+ targetFolder: $(Build.ArtifactStagingDirectory)/$(BuildOutputDirectory)
flattenFolders: true
- task: DotNetCoreCLI@2
@@ -57,13 +72,8 @@ jobs:
arguments: -c $(BuildConfiguration) --no-build --no-restore
displayName: Run Unittests
- - powershell: |
- & "$env:userprofile/.nuget/packages/xunit.runner.console/2.4.1/tools/net472/xunit.console.x86.exe" (Get-Childitem -Filter "BuildVision.IntegrationTests.dll" -Recurse | Where-Object {$_.FullName -like "*\bin\$(BuildConfiguration)\*" }).FullName
- displayName: Execute Integration Tests
- enabled: false
-
- task: PublishBuildArtifacts@1
inputs:
- PathtoPublish: $(Build.ArtifactStagingDirectory)/artifacts
- ArtifactName: artifacts
+ PathtoPublish: $(Build.ArtifactStagingDirectory)/$(BuildOutputDirectory)
+ ArtifactName: $(BuildOutputDirectory)
publishLocation: Container
\ No newline at end of file
diff --git a/src/BuildVision.Common/Diagnostics/DiagnosticsClient.cs b/src/BuildVision.Common/Diagnostics/DiagnosticsClient.cs
index 62006f2b..3bb88059 100644
--- a/src/BuildVision.Common/Diagnostics/DiagnosticsClient.cs
+++ b/src/BuildVision.Common/Diagnostics/DiagnosticsClient.cs
@@ -11,25 +11,24 @@ public static class DiagnosticsClient
private static bool _initialized;
private static TelemetryClient _client;
+ public static bool ParticipateInTelemetry { get; set; } = true;
- public static void Initialize(string apiKey)
+ public static void Initialize(string edition, string vsVersion, string apiKey)
{
if (!string.IsNullOrWhiteSpace(apiKey))
{
- TelemetryConfiguration.Active.InstrumentationKey = apiKey;
TelemetryConfiguration.Active.TelemetryChannel.DeveloperMode = Debugger.IsAttached;
TelemetryConfiguration.Active.TelemetryInitializers.Add(new VersionTelemetry());
- TelemetryConfiguration.Active.TelemetryInitializers.Add(new SessionTelemetry());
+ TelemetryConfiguration.Active.TelemetryInitializers.Add(new SessionTelemetry(vsVersion, edition));
_initialized = true;
-
_client = new TelemetryClient();
}
}
public static void OnExit()
{
- if (!_initialized)
+ if (!_initialized || !ParticipateInTelemetry)
{
return;
}
@@ -41,7 +40,7 @@ public static void OnExit()
public static void TrackEvent(string eventName, IDictionary properties = null, IDictionary metrics = null)
{
- if (!_initialized)
+ if (!_initialized || !ParticipateInTelemetry)
{
return;
}
@@ -49,19 +48,19 @@ public static void TrackEvent(string eventName, IDictionary prop
_client.TrackEvent(eventName, properties, metrics);
}
- public static void TrackTrace(string evt)
+ public static void TrackTrace(string trace)
{
- if (!_initialized)
+ if (!_initialized || !ParticipateInTelemetry)
{
return;
}
- _client.TrackTrace(evt);
+ _client.TrackTrace(trace);
}
- public static void Notify(Exception exception)
+ public static void TrackException(Exception exception)
{
- if (!_initialized)
+ if (!_initialized || !ParticipateInTelemetry)
{
return;
}
@@ -71,7 +70,7 @@ public static void Notify(Exception exception)
public static void TrackPageView(string pageName)
{
- if (!_initialized)
+ if (!_initialized || !ParticipateInTelemetry)
{
return;
}
diff --git a/src/BuildVision.Common/Diagnostics/SessionTelemetry.cs b/src/BuildVision.Common/Diagnostics/SessionTelemetry.cs
index 5243b33d..24ae1db1 100644
--- a/src/BuildVision.Common/Diagnostics/SessionTelemetry.cs
+++ b/src/BuildVision.Common/Diagnostics/SessionTelemetry.cs
@@ -13,8 +13,20 @@ class SessionTelemetry : ITelemetryInitializer
private readonly string _userName;
private readonly string _operatingSystem = RuntimeInformation.OSDescription?.Replace("Microsoft ", ""); // Shorter description
private readonly string _session = Guid.NewGuid().ToString();
+ private readonly string _vsVersion;
+ private readonly string _dteEdition;
- public SessionTelemetry()
+#if VSIXGallery
+ private const string Channel = "vsixgallery";
+#elif MARKETPLACE
+ private const string Channel = "marketplace";
+#elif VSIX
+ private const string Channel = "vsix";
+#else
+ private const string Channel = "vsix";
+#endif
+
+ public SessionTelemetry(string vsVersion, string dteEdition)
{
try
{
@@ -28,11 +40,14 @@ public SessionTelemetry()
{
// No user id
}
+
+ _vsVersion = vsVersion;
+ _dteEdition = dteEdition;
}
public void Initialize(ITelemetry telemetry)
{
- telemetry.Context.GlobalProperties["Environment"] = "release";
+ telemetry.Context.GlobalProperties["Environment"] = Channel;
// Always default to development if we're in the debugger
if (Debugger.IsAttached)
{
@@ -46,6 +61,8 @@ public void Initialize(ITelemetry telemetry)
telemetry.Context.Session.Id = _session;
telemetry.Context.Device.OperatingSystem = _operatingSystem;
+ telemetry.Context.Device.Model = _vsVersion;
+ telemetry.Context.Device.Type = _dteEdition;
}
}
}
diff --git a/src/BuildVision.Common/Diagnostics/VersionTelemetry.cs b/src/BuildVision.Common/Diagnostics/VersionTelemetry.cs
index f2419183..1fcc320f 100644
--- a/src/BuildVision.Common/Diagnostics/VersionTelemetry.cs
+++ b/src/BuildVision.Common/Diagnostics/VersionTelemetry.cs
@@ -1,4 +1,5 @@
using System;
+using System.Diagnostics;
using System.Linq;
using System.Reflection;
using Microsoft.ApplicationInsights.Channel;
@@ -12,9 +13,10 @@ class VersionTelemetry : ITelemetryInitializer
public VersionTelemetry()
{
- _appVersion = typeof(DiagnosticsClient).Assembly.GetCustomAttributes()
- .FirstOrDefault(ama => string.Equals(ama.Key, "CloudBuildNumber", StringComparison.OrdinalIgnoreCase))
- ?.Value;
+ var assembly = Assembly.GetExecutingAssembly();
+ var versionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
+
+ _appVersion = versionInfo.ProductVersion.ToString();
}
public void Initialize(ITelemetry telemetry)
diff --git a/src/BuildVision.UI/Resources.Designer.cs b/src/BuildVision.UI/Resources.Designer.cs
index 7ddc39b9..504fb22b 100644
--- a/src/BuildVision.UI/Resources.Designer.cs
+++ b/src/BuildVision.UI/Resources.Designer.cs
@@ -19,7 +19,7 @@ namespace BuildVision.UI {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Resources {
@@ -692,6 +692,15 @@ public static string GeneralSettings_NavigateToBuildFailureReasonLabelToolTip {
}
}
+ ///
+ /// Looks up a localized string similar to Help improve BuildVision by providing anynonymous usage data and crash reports.
+ ///
+ public static string GeneralSettings_ParticipateInTelemetry {
+ get {
+ return ResourceManager.GetString("GeneralSettings_ParticipateInTelemetry", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Reset progress after build done.
///
diff --git a/src/BuildVision.UI/Resources.resx b/src/BuildVision.UI/Resources.resx
index 5e12b259..27ee9cc9 100644
--- a/src/BuildVision.UI/Resources.resx
+++ b/src/BuildVision.UI/Resources.resx
@@ -607,4 +607,7 @@ on build done
Up-to-date Projects
+
+ Help improve BuildVision by providing anynonymous usage data and crash reports
+
\ No newline at end of file
diff --git a/src/BuildVision.UI/Settings/GeneralSettingsControl.xaml b/src/BuildVision.UI/Settings/GeneralSettingsControl.xaml
index bbd9f3c2..5c66c702 100644
--- a/src/BuildVision.UI/Settings/GeneralSettingsControl.xaml
+++ b/src/BuildVision.UI/Settings/GeneralSettingsControl.xaml
@@ -130,6 +130,10 @@
Content="{x:Static res:Resources.BuildMessagesSettings_HideUpToDateTargets}"
IsChecked="{Binding HideUpToDateTargets}" />
+
+
diff --git a/src/BuildVision.UI/Settings/Models/GeneralSettings.cs b/src/BuildVision.UI/Settings/Models/GeneralSettings.cs
index 61ac7295..55c38961 100644
--- a/src/BuildVision.UI/Settings/Models/GeneralSettings.cs
+++ b/src/BuildVision.UI/Settings/Models/GeneralSettings.cs
@@ -20,11 +20,14 @@ public class GeneralSettings : SettingsBase
public bool FillProjectListOnBuildBegin { get; set; }
+ public bool ParticipateInTelemetry { get; set; }
+
public GeneralSettings()
{
BuildProgressSettings = new BuildProgressSettings();
EnableStatusBarOutput = true;
IndicatorsPanelVisible = true;
+ ParticipateInTelemetry = true;
}
}
}
diff --git a/src/BuildVision/Core/BuildVisionPackage.cs b/src/BuildVision/Core/BuildVisionPackage.cs
index b8653396..08e0e1c0 100644
--- a/src/BuildVision/Core/BuildVisionPackage.cs
+++ b/src/BuildVision/Core/BuildVisionPackage.cs
@@ -1,5 +1,6 @@
using System;
using System.Diagnostics;
+using System.Globalization;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows;
@@ -68,12 +69,31 @@ public BuildVisionPackage()
{
Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;
}
+
+ DiagnosticsClient.Initialize(GetEdition(), VisualStudioVersion.ToString(), "c437ad44-0c76-4006-968d-42d4369bc0ed");
+ }
+
+ public static Version VisualStudioVersion => GetGlobalService(typeof(DTE)) is DTE dte
+ ? new Version(int.Parse(dte.Version.Split('.')[0], CultureInfo.InvariantCulture), 0)
+ : new Version(0, 0, 0, 0);
+
+ private string GetEdition()
+ {
+ try
+ {
+ _dte2 = GetService(typeof(DTE)) as DTE2;
+ return _dte2.Edition;
+ }
+ catch (Exception ex)
+ {
+ return "";
+ }
}
private void Current_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
_logger.Fatal(e.Exception, "Unhandled Exception");
- DiagnosticsClient.Notify(e.Exception);
+ DiagnosticsClient.TrackException(e.Exception);
}
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress progress)
diff --git a/src/BuildVision/Services/PackageSettingsProvider.cs b/src/BuildVision/Services/PackageSettingsProvider.cs
index 62e988c1..0edddbae 100644
--- a/src/BuildVision/Services/PackageSettingsProvider.cs
+++ b/src/BuildVision/Services/PackageSettingsProvider.cs
@@ -2,6 +2,7 @@
using System.Diagnostics;
using System.Windows;
using BuildVision.Common;
+using BuildVision.Common.Diagnostics;
using BuildVision.Common.Logging;
using BuildVision.UI.Settings.Models;
using Microsoft.VisualStudio.Settings;
@@ -31,6 +32,8 @@ public void Save()
{
SaveSettings();
SettingsChanged?.Invoke();
+
+ DiagnosticsClient.ParticipateInTelemetry = Settings.GeneralSettings.ParticipateInTelemetry;
}
private void SaveSettings()
@@ -59,6 +62,8 @@ private void LoadSettings()
{
Settings = new ControlSettings();
}
+
+ DiagnosticsClient.ParticipateInTelemetry = Settings.GeneralSettings.ParticipateInTelemetry;
}
catch (Exception ex)
{