diff --git a/src/DataCollectors/TraceDataCollector/Microsoft.VisualStudio.TraceDataCollector.csproj b/src/DataCollectors/TraceDataCollector/Microsoft.VisualStudio.TraceDataCollector.csproj
index a1f23c7cae..b88a138708 100644
--- a/src/DataCollectors/TraceDataCollector/Microsoft.VisualStudio.TraceDataCollector.csproj
+++ b/src/DataCollectors/TraceDataCollector/Microsoft.VisualStudio.TraceDataCollector.csproj
@@ -15,6 +15,7 @@
+
diff --git a/src/DataCollectors/TraceDataCollector/VanguardCollector/DynamicCoverageDataCollectorImpl.cs b/src/DataCollectors/TraceDataCollector/VanguardCollector/DynamicCoverageDataCollectorImpl.cs
index bac2a03655..40a8a9a38f 100644
--- a/src/DataCollectors/TraceDataCollector/VanguardCollector/DynamicCoverageDataCollectorImpl.cs
+++ b/src/DataCollectors/TraceDataCollector/VanguardCollector/DynamicCoverageDataCollectorImpl.cs
@@ -11,6 +11,7 @@ namespace Microsoft.VisualStudio.Coverage
using System.Xml;
using Interfaces;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection;
+ using Microsoft.VisualStudio.TestPlatform.Utilities;
using TestPlatform.ObjectModel;
using TraceCollector;
using TraceCollector.Interfaces;
@@ -107,10 +108,29 @@ public virtual void Initialize(
IDataCollectionSink dataSink,
IDataCollectionLogger logger)
{
+ var defaultConfigurationElement = DynamicCoverageDataCollectorImpl.GetDefaultConfiguration();
+
+ try
+ {
+ var processor = new CodeCoverageRunSettingsProcessor(defaultConfigurationElement);
+ configurationElement = (XmlElement)processor.Process(configurationElement);
+ }
+ catch (Exception ex)
+ {
+ EqtTrace.Warning(
+ string.Format(
+ CultureInfo.CurrentCulture,
+ string.Join(
+ " ",
+ "DynamicCoverageDataCollectorImpl.Initialize: Exception encountered while processing the configuration element.",
+ "Keeping the configuration element unaltered. More info about the exception: {0}"),
+ ex.Message));
+ }
+
EqtTrace.Info("DynamicCoverageDataCollectorImpl.Initialize: Initialize configuration. ");
if (string.IsNullOrEmpty(configurationElement?.InnerXml))
{
- configurationElement = DynamicCoverageDataCollectorImpl.GetDefaultConfiguration();
+ configurationElement = defaultConfigurationElement;
}
this.logger = logger;
diff --git a/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionAttachmentManager.cs b/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionAttachmentManager.cs
index be447f7fc0..f1606df6b6 100644
--- a/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionAttachmentManager.cs
+++ b/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionAttachmentManager.cs
@@ -17,6 +17,7 @@ namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
+ using Microsoft.VisualStudio.TestPlatform.Utilities;
using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces;
///
@@ -117,11 +118,21 @@ public void Initialize(SessionId id, string outputDirectory, IMessageSink messag
this.SessionOutputDirectory = Path.Combine(absolutePath, id.Id.ToString());
}
- // Create the output directory if it doesn't exist.
- if (!Directory.Exists(this.SessionOutputDirectory))
+ try
+ {
+ // Create the output directory if it doesn't exist.
+ if (!Directory.Exists(this.SessionOutputDirectory))
+ {
+ Directory.CreateDirectory(this.SessionOutputDirectory);
+ }
+ }
+ catch (UnauthorizedAccessException accessException)
{
- Directory.CreateDirectory(this.SessionOutputDirectory);
+ string accessDeniedMessage = string.Format(CultureInfo.CurrentCulture, Resources.Resources.AccessDenied, accessException.Message);
+ ConsoleOutput.Instance.Error(false, accessDeniedMessage);
+ throw;
}
+
}
///
diff --git a/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs b/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs
index 4907235e78..4e54d9b88e 100644
--- a/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs
+++ b/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs
@@ -60,6 +60,15 @@ internal Resources() {
}
}
+ ///
+ /// Looks up a localized string similar to {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message:.
+ ///
+ internal static string AccessDenied {
+ get {
+ return ResourceManager.GetString("AccessDenied", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Cancelling the operation as requested..
///
diff --git a/src/Microsoft.TestPlatform.Common/Resources/Resources.resx b/src/Microsoft.TestPlatform.Common/Resources/Resources.resx
index 42d99d6496..3bd129b67e 100644
--- a/src/Microsoft.TestPlatform.Common/Resources/Resources.resx
+++ b/src/Microsoft.TestPlatform.Common/Resources/Resources.resx
@@ -117,6 +117,9 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message:
+
Cancelling the operation as requested.
diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.cs.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.cs.xlf
index fed20b4eb1..d133688a44 100644
--- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.cs.xlf
+++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.cs.xlf
@@ -279,6 +279,11 @@
Nepovedlo se načíst rozšíření ze souboru {0}. Další informace získáte pomocí parametru /diag.
+
+
+ Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges.
+
+