Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

Backport changes required for XI/XM's msbuild port #63

Closed
wants to merge 7 commits into from

Conversation

radical
Copy link
Member

@radical radical commented May 22, 2018

Specifically, PRs: #59 and #60

radical and others added 7 commits May 21, 2018 20:01
…rty (dotnet#59)

* Add support for fallback paths to be specified via property references

Currently, the list of fallback paths in app.config can have a property
reference, like:

```
 <searchPaths os="osx">
	<property name="MSBuildExtensionsPath" value="$(FallbackPath);/x/y/z" />
```

.. but it is assumed that such a property will expand to a single path.

This commit adds support for such properties to expand to multiple ';'
separated list of paths. The rules for expansion do not change, they are still
expanded at the time of project import.

With this, given `$(FallbackPath)="/a/b/c;/q/w/e"` and the list of fallback paths
would become `"/a/b/c;/q/w/e;/x/yz"`.

* [osx] Add property allowing users to override fallback paths for ..

.. MSBuildExtensionsPath.

For OSX, this essentially sets the fallback paths to:

`<property name="MSBuildExtensionsPath" value="$(MSBuildExtensionsPathFallbackPathsOverride);/Library/Frameworks/Mono.framework/External/xbuild/" />`

.. whichs allows the default fallback paths to be overridden by setting
a property - `$(MSBuildExtensionsPathFallbackPathsOverride)`.

One of the useful use cases for this is to be able to run tests with
in-tree builds of assemblies/targets meant for
`$(MSBuildExtensionsPath)/`. Simply changing `$(MSBuildExtensionsPath)` would
mean that the in-tree builds of the custom frameworks would work but the
default ones would not be found!

(cherry picked from commit c4e70a6)
…works"

This reverts commit 0826df1.

(cherry picked from commit b549fb3)
.. in preparation for upcoming commits.

(cherry picked from commit c27d895)
.. search paths.

`ToolLocationHelper.GetPathTo{StandardLibraries,ReferenceAssemblies}`
look for the target framework in the path specified by
@targetFrameworkRootPath parameter (roughly corresponding to the
$(TargetFrameworkRootPath) property) or the default path.

It would be useful to be able to look for these frameworks in more than
one location. For example, in case of Xamarin products on OSX, mobile
specific frameworks are installed in
`/Library/Frameworks/Mono.framework/External/xbuild-frameworks` and the
.NET ones are installed in
`/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/xbuild-frameworks` .

With support for fallback search paths, a lookup for a target framework will follow the order:

		1. @targetFrameworkRootPath or default location if @targetFrameworkRootPath is ''
		2. Fallback search paths

APIs changed:

GetPathToStandardLibraries(string targetFrameworkIdentifier, string targetFrameworkVersion, string targetFrameworkProfile, string platformTarget, string targetFrameworkRootPath)
	changed to => GetPathToStandardLibraries(string targetFrameworkIdentifier, string targetFrameworkVersion, string targetFrameworkProfile, string platformTarget, string targetFrameworkRootPath, string targetFrameworkFallbackSearchPaths = null)

GetPathToReferenceAssemblies(string targetFrameworkIdentifier, string targetFrameworkVersion, string targetFrameworkProfile, string platformTarget, string targetFrameworkRootPath)
	changed to => GetPathToReferenceAssemblies(string targetFrameworkIdentifier, string targetFrameworkVersion, string targetFrameworkProfile, string platformTarget, string targetFrameworkRootPath, string targetFrameworkFallbackSearchPaths = null)

New overload:

GetPathToReferenceAssemblies(string targetFrameworkRootPath, string targetFrameworkFallbackSearchPaths, FrameworkNameVersioning frameworkName)

- The reason for using a `targetFrameworkRootPath` parameter separate from
the `targetFrameworkFallbackSearchPaths` is that we need to
automatically fallback to a default path, which is being determined in
code (`FrameworkLocationHelper.programFilesReferenceAssemblyLocation`).

- Also, the parameter `targetFrameworkRootPath` roughly corresponds to the
`$(TargetFrameworkRootPath)` property and changing that to have multiple
paths would change it's meaning.

(cherry picked from commit 3d34ef6)
.. property. This specifies a list of ';' separated paths which are used
as fallback search paths, for looking up the target framework, if could
not be found in @rootpath.

(cherry picked from commit 06aea53)
.. frameworks. This contains ';' separated list of paths. When
`GetReferenceAssemblyPaths` task will look for assemblies corresponding to a
target framework, then it will try to find it in multiple locations:

	1. $(TargetFrameworkRootPath) or the default path if
	$(TargetFrameworkRootPath) is ''

	2. Each path in $(TargetFrameworkFallbackSearchPaths)

(cherry picked from commit a90074b)
- This sets up the $(TargetFrameworkFallbackSearchPaths) to point to
  `/Library/Frameworks/Mono.framework/External/xbuild-frameworks` on
  mono/osx. This location is used by Xamarin to install frameworks.
  The .net frameworks are available in usual default location.

  So, effectively, target frameworks are looked up, in order:

  1. $(TargetFrameworkRootPath) or the default location, if
	 $(TargetFrameworkRootPath) is ''

  2. If not found in (1), then try to find it in the fallback search
	 paths specified in $(TargetFrameworkFallbackSearchPaths)

Note that we always add the `External` as the last fallback path on
`$(TargetFrameworkFallbackSearchPaths)`.

Rationale:

When running on Mono, target frameworks are searched for in
`$mono_prefix/lib/mono/xbuild-frameworks`, which becomes
`/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/xbuild-frameworks`.

This works, but has a problem when upgrading the Mono.framework package:
a *new* `/Library/Frameworks/Mono.framework/Versions/@Version@` directory
is created, so anything installed into the previous directory will be
"lost". The file is still there, but xbuild will no longer find it.

To address this upgrade scenario, Mono's xbuild also checks a fallback path:

	`/Library/Frameworks/Mono.framework/External/xbuild-frameworks`

This location is not within a versioned framework directory, and thus files
installed into it will survive Mono.framework package upgrades.

This also allows overriding the root path to test in-tree builds of custom target
frameworks. Simply changing `$(TargetFrameworkRootPath)` would mean that
the in-tree builds of the custom frameworks would work but the default
ones would not be found!

(cherry picked from commit 0fa0323)
@marek-safar
Copy link
Member

Why do we need that in 2018-02? We are working on 2018-04 so it should be fine to land it there only

@radical radical closed this May 28, 2018
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.

2 participants