-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Use MSBuildLocator for tests #57613
Use MSBuildLocator for tests #57613
Conversation
@@ -2,7 +2,7 @@ | |||
|
|||
<PropertyGroup> | |||
<OutputType>Exe</OutputType> | |||
<TargetFramework>netcoreapp2.1</TargetFramework> | |||
<TargetFramework>netcoreapp3.1</TargetFramework> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we change the folder name to match? or maybe remove the version from the folder?
3a674da
to
1da68bf
Compare
src/Workspaces/MSBuildTest/Resources/ProjectFiles/CSharp/AdditionalFile.csproj
Show resolved
Hide resolved
@@ -22,6 +22,7 @@ public override string SkipReason | |||
|
|||
static DotNetCoreSdk() | |||
{ | |||
#if NETCOREAPP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this change necessary here? Trying to understand how this PR could have caused an error here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't really make sense to use the .NET SDK from .NET Framework. essentially if we are running tests from .NET Framework we do not want SDK-based tests to run.
.OrderByDescending(instances => instances.Version) | ||
.FirstOrDefault(); | ||
|
||
if (s_instance != null && !MSBuildLocator.IsRegistered) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When can s_instance
be non-null here?
: base(minimumVsVersion: new Version(16, 9), minimumSdkVersion: new Version(5, 0, 201)) | ||
{ | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than having a type per common version why not just have the ctor of MSBuildInstalled
take a string constant that can be parsed into a version? Then we can export constants for all the versions that matter. Seems less heavy handed than inheritance.
src/Workspaces/MSBuildTest/Resources/CircularProjectReferences/CircularCSharpProject1.csproj
Outdated
Show resolved
Hide resolved
da3d724
to
acba73b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of NET6_0
define in the change is brittle. Would like to understand why we can't use one of the more flexible defines or barring that how we make this code resilient to future target framework changes.
@@ -25,26 +25,33 @@ static DotNetSdkMSBuildInstalled() | |||
} | |||
} | |||
|
|||
#if NET6_0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This #if
pattern is fragile in the face of changing target frameworks. Consider either using NET6_0_OR_GREATER
or NETCOREAPP
. if this must change when we change the target framework then please use the following pattern
#if NET6_0
...
#elif NETCOREAPP
#error bad target framework
#endif
using Microsoft.Build.Locator; | ||
using Roslyn.Test.Utilities; | ||
|
||
namespace Microsoft.CodeAnalysis.MSBuild.UnitTests | ||
{ | ||
internal partial class DotNetSdkMSBuildInstalled : ExecutionCondition | ||
{ | ||
#if NETCOREAPP3_1_OR_GREATER |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious: is there a reason you prefer this over #if NETCOREAPP
? don't think we use earlier than netcoreapp3.1
anymore.
c404d64
to
29fba84
Compare
…/CircularCSharpProject1.csproj Co-authored-by: Jared Parsons <jaredpparsons@gmail.com>
Co-authored-by: Jared Parsons <jaredpparsons@gmail.com>
baaf703
to
9109b93
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
builds on top of @JoeRobich 's excellent work in this PR: #52064