Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Clean up OS-related property uses, update buildtools, update MSBuild #15728

Merged
merged 3 commits into from
Feb 2, 2017

Conversation

mellinoe
Copy link
Contributor

@mellinoe mellinoe commented Feb 2, 2017

This fixes https://github.com/dotnet/corefx/issues/15305, taking the approach I described over in that issue.

I've also updated buildtools as part of this, which pulls in a new version of .NET Core MSBuild. With all these changes, I'm able to do the full managed build on Windows using the .NET Core version of MSBuild. The native build does not work with .NET Core MSBuild, but that would require some more thought and more changes. I haven't changed the default in any way, just tested that it was possible.

@weshaggard

Our targets should now be able to use the following properties in all cases:

* RunningOnCore : This is determined by MSBuildRuntimeType. This should only
  control MSBuild-related stuff, like the path to the task assembly being used,
  or which Roslyn props file is imported (different behavior on .NET Core).
* RunningOnUnix: This will be used to control things like path separators,
  environment variable syntax, executable file suffix, etc. which are the same
  everywhere except for Windows. This is determined by the value of OS. Any value
  other than Windows_NT will result in RunningOnUnix being set to true.
* TargetOS: This represents the target operating system for tests. "OSGroup"
  cannot be re-used for this because most tests are generally built for the
  "AnyOS" group, which does not accurately represent the OS being run on.
* OSGroup: This should be able to supplant all other uses of OS and OSEnvironment.
  This property is already defaulted to the correct value (based on the local
  environment) if it is not set.
This updates the version of .NET Core MSBuild used. A line was changed in
Roslyn.Common.props which has been replicated here in this copy of the
file.
@mellinoe
Copy link
Contributor Author

mellinoe commented Feb 2, 2017

This is mostly just cleanup and renaming so I'm gonna go ahead and merge it. I can do some further cleanup if there's feedback.

@mellinoe mellinoe merged commit 99511c7 into dotnet:master Feb 2, 2017
<PropertyGroup>
<TargetOS Condition="'$(TargetOS)' == ''">$(DefaultOSGroup)</TargetOS>
Copy link
Member

Choose a reason for hiding this comment

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

This isn't enough to correctly filter for the other OS's. DefaultOSGroup will only ever have OSX, Unix, or Windows_NT. I expect this will break some tests. See TargetOSTrait above for example it has some other targets.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

DefaultOSGroup is set to Linux in cases where $(OS) == Unix and the /Applications/ folder doesn't exist (it should only exist on OSX).

Copy link
Member

Choose a reason for hiding this comment

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

What about FreeBSD/NetBSD? will those ever be set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They will not, but we don't use those anywhere right now. We'd probably need to add some extra logic to auto-detect it, or go back to using the build task for that.

Copy link
Member

Choose a reason for hiding this comment

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

OK can you clean those out then if they are dead. I would like to keep these things consistent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's fine to keep them. There are a couple of tests that have [PlatformSpecific(TestPlatforms.FreeBSD)], it's just that we do not have any runs that would ever use that right now. If you were trying to run those tests, you would just need to specify TargetOS=FreeBSD manually.

Copy link
Member

@weshaggard weshaggard left a comment

Choose a reason for hiding this comment

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

LGTM beyond the one comment about TargetOS. If you do feel like we don't need the other ones we should probably completely remove TargetOS and use DefaultOSGroup directly.

@karelz karelz modified the milestone: 2.0.0 Feb 4, 2017
@@ -23,10 +23,12 @@

<!-- Platform detection -->
<PropertyGroup>
<OsEnvironment Condition="'$(OsEnvironment)'=='' AND '$(OS)'=='Unix' AND Exists('/Applications')">OSX</OsEnvironment>
<OsEnvironment Condition="'$(OsEnvironment)'=='' AND '$(OS)'=='Unix'">Linux</OsEnvironment>
<OsEnvironment Condition="'$(OsEnvironment)'==''">$(OS)</OsEnvironment>
Copy link
Member

@akoeplinger akoeplinger Feb 7, 2017

Choose a reason for hiding this comment

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

@mellinoe noticed this while looking at the other problem: there are still a few targets in buildtools that rely on OsEnvironment being set, e.g.: https://github.com/dotnet/buildtools/search?utf8=%E2%9C%93&q=OsEnvironment

I think with this change those would be doing the wrong thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah there are a few things in there that would be broken, although most of the interesting ones are being overridden here. I'll file an issue in buildtools to clean those up when we integrate the corefx changes back into there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clean-up usage of $(OS) property in targets
5 participants