Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toolset configuration net5.0 #6220

Merged
merged 20 commits into from Mar 11, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions eng/Packages.props
Expand Up @@ -19,6 +19,7 @@
<PackageReference Update="System.CodeDom" Version="4.4.0" />
<PackageReference Update="System.Collections.Concurrent" Version="4.3.0" />
<PackageReference Update="System.Collections.Immutable" Version="5.0.0" />
<PackageReference Update="System.Configuration.ConfigurationManager" Version="5.0.0" />
<PackageReference Update="System.Diagnostics.TraceSource" Version="4.0.0" />
<PackageReference Update="System.IO.Compression" Version="4.3.0" />
<PackageReference Update="System.IO.FileSystem.Primitives" Version="4.3.0" />
Expand All @@ -36,8 +37,8 @@
<PackageReference Update="System.Runtime.Serialization.Primitives" Version="4.1.1" />
<PackageReference Update="System.Security.Cryptography.Pkcs" Version="4.7.0" />
<PackageReference Update="System.Security.Cryptography.Xml" Version="4.7.0" />
<PackageReference Update="System.Security.Permissions" Version="4.7.0" />
<PackageReference Update="System.Security.Principal.Windows" Version="4.7.0" />
<PackageReference Update="System.Security.Permissions" Version="5.0.0" />
<PackageReference Update="System.Security.Principal.Windows" Version="5.0.0" />
<PackageReference Update="System.Text.Encoding.CodePages" Version="4.0.1" />
<PackageReference Update="System.Text.Json" Version="4.7.0" />
<PackageReference Update="System.Threading.Tasks.Dataflow" Version="4.9.0" />
Expand Down
@@ -1,10 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#if FEATURE_SYSTEM_CONFIGURATION

using System.Configuration;
using Microsoft.Win32;
using Microsoft.Build.Collections;
using Microsoft.Build.Evaluation;
using Microsoft.Build.Execution;
Expand Down Expand Up @@ -683,4 +680,3 @@ private ToolsetConfigurationReader GetStandardConfigurationReader()

}
}
#endif
2 changes: 0 additions & 2 deletions src/Build.UnitTests/Definition/ToolsetReader_Tests.cs
Expand Up @@ -3,9 +3,7 @@

using System;
using System.Collections.Generic;
#if FEATURE_SYSTEM_CONFIGURATION
using System.Configuration;
#endif
using System.IO;

using Microsoft.Build.Collections;
Expand Down
Expand Up @@ -2,9 +2,12 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#if FEATURE_SYSTEM_CONFIGURATION
// NOTE: This test WOULD work in net5.0 after the System.Configuration.ConfigurationManager change. However, it would
// only work if ToolsetDefinitionLocations is set to ConfigurationFile and that ReadApplicationConfiguration in
// ToolsetConfigurationReader.cs removes the RunningTests condition since ConfigurationManager.OpenExeConfiguration
// would try to get testhost.exe.config instead of the actual configuration file. But those changes seems more
// fitting as a different test rather than making all these changes instead.

using System.Configuration;
using Microsoft.Win32;
using Microsoft.Build.Collections;
using Microsoft.Build.Evaluation;
using Microsoft.Build.Exceptions;
Expand All @@ -15,7 +18,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Build.UnitTests;

namespace Microsoft.Build.UnitTests.Evaluation
{
Expand Down
8 changes: 2 additions & 6 deletions src/Build.UnitTests/Microsoft.Build.Engine.UnitTests.csproj
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hyper-Nit: Is this a BOM change from a text editor?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep seems like it... Though I thought I only opened it in VS so it's odd but it should be fixed now 👍


<PropertyGroup>
<TargetFrameworks>$(RuntimeOutputTargetFrameworks)</TargetFrameworks>
Expand All @@ -17,6 +17,7 @@

<ItemGroup>
<PackageReference Include="System.Collections.Concurrent" />
<PackageReference Include="System.Configuration.ConfigurationManager" />
<PackageReference Include="Shouldly" />
<PackageReference Include="Microsoft.CodeAnalysis.Build.Tasks" />
<PackageReference Include="NuGet.Frameworks" >
Expand Down Expand Up @@ -45,17 +46,12 @@
<SetTargetFramework Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' and '$(MonoBuild)' == 'true'">TargetFramework=$(FullFrameworkTFM)</SetTargetFramework>
<SetTargetFramework Condition="'$(TargetFrameworkIdentifier)' != '.NETFramework'">TargetFramework=net5.0</SetTargetFramework>
</ProjectReference>

<Reference Include="System.Configuration" Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\Shared\FxCopExclusions\Microsoft.Build.Shared.Suppressions.cs">
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
</Compile>

<Compile Remove="Definition\ToolsetConfigurationReaderTestHelper.cs" />
<Compile Include="Definition\ToolsetConfigurationReaderTestHelper.cs" Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'" />

<Compile Include="..\Shared\UnitTests\BuildEventArgsExtension.cs">
<!-- Extension methods -->
Expand Down
10 changes: 2 additions & 8 deletions src/Build/Definition/ProjectCollection.cs
Expand Up @@ -1729,15 +1729,13 @@ private void CreateLoggingService(int maxCPUCount, bool onlyLogCriticalEvents)
_loggingService.OnlyLogCriticalEvents = onlyLogCriticalEvents;
}

#if FEATURE_SYSTEM_CONFIGURATION
/// <summary>
/// Reset the toolsets using the provided toolset reader, used by unit tests
/// </summary>
internal void ResetToolsetsForTests(ToolsetConfigurationReader configurationReaderForTestsOnly)
{
InitializeToolsetCollection(configReader:configurationReaderForTestsOnly);
}
#endif

#if FEATURE_WIN32_REGISTRY
/// <summary>
Expand All @@ -1757,9 +1755,7 @@ internal void ResetToolsetsForTests(ToolsetRegistryReader registryReaderForTests
#if FEATURE_WIN32_REGISTRY
ToolsetRegistryReader registryReader = null,
#endif
#if FEATURE_SYSTEM_CONFIGURATION
ToolsetConfigurationReader configReader = null
#endif
)
{
_toolsets = new Dictionary<string, Toolset>(StringComparer.OrdinalIgnoreCase);
Expand All @@ -1769,9 +1765,7 @@ internal void ResetToolsetsForTests(ToolsetRegistryReader registryReaderForTests
#if FEATURE_WIN32_REGISTRY
registryReader,
#endif
#if FEATURE_SYSTEM_CONFIGURATION
configReader,
#endif
EnvironmentProperties, _globalProperties, ToolsetLocations);

_toolsetsVersion++;
Expand Down Expand Up @@ -2038,9 +2032,9 @@ public void IncludeTaskInputs()

_includeTaskInputs = true;
}
#endregion
#endregion

#region ILogger Members
#region ILogger Members

/// <summary>
/// The logger verbosity
Expand Down
8 changes: 0 additions & 8 deletions src/Build/Definition/ToolsetReader.cs
Expand Up @@ -76,7 +76,6 @@ internal abstract class ToolsetReader
get;
}

#if FEATURE_WIN32_REGISTRY || FEATURE_SYSTEM_CONFIGURATION
/// <summary>
/// Gathers toolset data from the registry and configuration file, if any:
/// allows you to specify which of the registry and configuration file to
Expand All @@ -88,12 +87,9 @@ internal static string ReadAllToolsets(Dictionary<string, Toolset> toolsets, Pro
#if FEATURE_WIN32_REGISTRY
null,
#endif
#if FEATURE_SYSTEM_CONFIGURATION
null,
#endif
environmentProperties, globalProperties, locations);
}
#endif

/// <summary>
/// Gathers toolset data from the registry and configuration file, if any.
Expand All @@ -105,9 +101,7 @@ internal static string ReadAllToolsets
#if FEATURE_WIN32_REGISTRY
ToolsetRegistryReader registryReader,
#endif
#if FEATURE_SYSTEM_CONFIGURATION
ToolsetConfigurationReader configurationReader,
#endif
PropertyDictionary<ProjectPropertyInstance> environmentProperties,
PropertyDictionary<ProjectPropertyInstance> globalProperties,
ToolsetDefinitionLocations locations
Expand All @@ -124,7 +118,6 @@ ToolsetDefinitionLocations locations
string overrideTasksPathFromConfiguration = null;
string defaultOverrideToolsVersionFromConfiguration = null;

#if FEATURE_SYSTEM_CONFIGURATION
if ((locations & ToolsetDefinitionLocations.ConfigurationFile) == ToolsetDefinitionLocations.ConfigurationFile)
{
if (configurationReader == null)
Expand All @@ -137,7 +130,6 @@ ToolsetDefinitionLocations locations
initialProperties, true /* accumulate properties */, out overrideTasksPathFromConfiguration,
out defaultOverrideToolsVersionFromConfiguration);
}
#endif

string defaultToolsVersionFromRegistry = null;
string overrideTasksPathFromRegistry = null;
Expand Down
5 changes: 1 addition & 4 deletions src/Build/Definition/ToolsetRegistryReader.cs
Expand Up @@ -3,11 +3,8 @@

#if FEATURE_WIN32_REGISTRY

using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.IO;
using System.Security;

using Microsoft.Build.Shared;
using error = Microsoft.Build.Shared.ErrorUtilities;
Expand Down Expand Up @@ -346,4 +343,4 @@ private static string GetValue(RegistryKeyWrapper wrapper, string valueName)
}
}
}
#endif
#endif
28 changes: 14 additions & 14 deletions src/Build/Evaluation/IntrinsicFunctions.cs
Expand Up @@ -259,30 +259,30 @@ internal static object GetRegistryValueFromView(string keyName, string valueName
return result;
}

#else // FEATURE_WIN32_REGISTRY is off, need to mock the function names to let scrips call these property functions and get NULLs rather than fail with errors
#else // FEATURE_WIN32_REGISTRY is off, need to mock the function names to let scrips call these property functions and get NULLs rather than fail with errors

/// <summary>
/// Get the value of the registry key and value, default value is null
/// </summary>
/// <summary>
/// Get the value of the registry key and value, default value is null
/// </summary>
internal static object GetRegistryValue(string keyName, string valueName)
{
return null; // FEATURE_WIN32_REGISTRY is off, need to mock the function names to let scrips call these property functions and get NULLs rather than fail with errors
return null; // FEATURE_WIN32_REGISTRY is off, need to mock the function names to let scrips call these property functions and get NULLs rather than fail with errors
}

/// <summary>
/// Get the value of the registry key and value
/// </summary>
/// <summary>
/// Get the value of the registry key and value
/// </summary>
internal static object GetRegistryValue(string keyName, string valueName, object defaultValue)
{
return defaultValue; // FEATURE_WIN32_REGISTRY is off, need to mock the function names to let scrips call these property functions and get NULLs rather than fail with errors
return defaultValue; // FEATURE_WIN32_REGISTRY is off, need to mock the function names to let scrips call these property functions and get NULLs rather than fail with errors
}

/// <summary>
/// Get the value of the registry key from one of the RegistryView's specified
/// </summary>
/// <summary>
/// Get the value of the registry key from one of the RegistryView's specified
/// </summary>
internal static object GetRegistryValueFromView(string keyName, string valueName, object defaultValue, params object[] views)
{
return defaultValue; // FEATURE_WIN32_REGISTRY is off, need to mock the function names to let scrips call these property functions and get NULLs rather than fail with errors
return defaultValue; // FEATURE_WIN32_REGISTRY is off, need to mock the function names to let scrips call these property functions and get NULLs rather than fail with errors
}
#endif

Expand Down Expand Up @@ -569,7 +569,7 @@ internal static List<string> __GetListTest()
return new List<string> { "A", "B", "C", "D" };
}

#endregion
#endregion

#if FEATURE_WIN32_REGISTRY
/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions src/Build/Microsoft.Build.csproj
Expand Up @@ -31,6 +31,7 @@
<ProjectReference Include="..\StringTools\StringTools.csproj" />

<PackageReference Include="System.Collections.Immutable" />
<PackageReference Include="System.Configuration.ConfigurationManager" />
<PackageReference Include="System.Threading.Tasks.Dataflow" />
<PackageReference Include="System.Memory" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe"/>
Expand All @@ -41,7 +42,6 @@

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<PackageReference Include="Microsoft.VisualStudio.Setup.Configuration.Interop" />
<Reference Include="System.Configuration" />
<Reference Include="System.IO.Compression" />
</ItemGroup>

Expand Down Expand Up @@ -419,8 +419,8 @@
<Compile Include="Definition\ResolvedImport.cs" />
<Compile Include="Definition\SubToolset.cs" />
<Compile Include="Definition\Toolset.cs" />
<Compile Include="Definition\ToolsetConfigurationReader.cs" Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'" />
<Compile Include="..\Shared\ToolsetElement.cs" Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<Compile Include="Definition\ToolsetConfigurationReader.cs" />
<Compile Include="..\Shared\ToolsetElement.cs">
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
</Compile>
<Compile Include="Definition\ToolsetPropertyDefinition.cs" />
Expand Down
4 changes: 0 additions & 4 deletions src/Build/Utilities/RegistryKeyWrapper.cs
Expand Up @@ -3,10 +3,6 @@
#if FEATURE_WIN32_REGISTRY

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Security;

using Microsoft.Build.Shared;
using Microsoft.Win32;
Expand Down
4 changes: 3 additions & 1 deletion src/MSBuild/MSBuild.csproj
Expand Up @@ -222,12 +222,14 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Configuration.ConfigurationManager" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<!-- File for Assemblies we depend on -->
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
<PackageReference Include="LargeAddressAware" PrivateAssets="All" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETFramework'">
Expand Down
2 changes: 0 additions & 2 deletions src/MSBuild/XMake.cs
Expand Up @@ -4,9 +4,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
#if FEATURE_SYSTEM_CONFIGURATION
using System.Configuration;
#endif
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
Expand Down
6 changes: 0 additions & 6 deletions src/Shared/FrameworkLocationHelper.cs
Expand Up @@ -4,17 +4,11 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
#if FEATURE_SYSTEM_CONFIGURATION
using System.Configuration;
#endif
using System.IO;
using System.Linq;
using System.Runtime.Versioning;
using Microsoft.Win32;

#if FEATURE_SYSTEM_CONFIGURATION
using PropertyElement = Microsoft.Build.Evaluation.ToolsetElement.PropertyElement;
#endif
using Microsoft.Build.Shared.FileSystem;

namespace Microsoft.Build.Shared
Expand Down
5 changes: 0 additions & 5 deletions src/Shared/ToolsetElement.cs
Expand Up @@ -3,17 +3,13 @@

using System;
using System.Collections.Generic;
#if FEATURE_SYSTEM_CONFIGURATION
using System.Configuration;
#endif
using System.IO;
using Microsoft.Build.Collections;
using Microsoft.Build.Shared;

namespace Microsoft.Build.Evaluation
{
#if FEATURE_SYSTEM_CONFIGURATION

/// <summary>
/// Helper class for reading toolsets out of the configuration file.
/// </summary>
Expand Down Expand Up @@ -708,5 +704,4 @@ public string DefaultOverrideToolsVersion
}
}
}
#endif
}
2 changes: 2 additions & 0 deletions src/Tasks.UnitTests/Copy_Tests.cs
Expand Up @@ -2397,7 +2397,9 @@ public void CopyToDestinationFolderWithSymbolicLinkCheck()

if (NativeMethodsShared.IsWindows)
{
#pragma warning disable CA1416 // Suppress Warning saying that WindowsPrincipal might not be compatible on Windows (Which shouldn't be an issue...)
if (!new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(new SecurityIdentifier(WellKnownSidType.BuiltinAdministratorsSid, null)))
#pragma warning restore CA1416 // Suppress Warning saying that WindowsPrincipal might not be compatible on Windows (Which shouldn't be an issue...)
{
isPrivileged = false;
Assert.True(true, "It seems that you don't have the permission to create symbolic links. Try to run this test again with higher privileges");
Expand Down
3 changes: 1 addition & 2 deletions src/Utilities/Microsoft.Build.Utilities.csproj
Expand Up @@ -22,12 +22,11 @@
<ProjectReference Include="..\StringTools\StringTools.csproj" />

<PackageReference Include="System.Collections.Immutable" />
<PackageReference Include="System.Configuration.ConfigurationManager" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETStandard'">
<PackageReference Include="Microsoft.VisualStudio.Setup.Configuration.Interop" />

<Reference Include="System.Configuration" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETStandard'">
Expand Down