Repository navigation
Add cross-targeting support - #154
Conversation
|
@brthor @livarcocc #Closed |
| <CustomBeforeMicrosoftCommonTargets>$(MSBuildThisFileDirectory)Microsoft.NETCore.Sdk.BeforeCommon.targets</CustomBeforeMicrosoftCommonTargets> | ||
| </PropertyGroup> | ||
|
|
||
| <!-- Shared properties between cross-targeting and inner build targets. --> |
There was a problem hiding this comment.
(nit) I think this section should go "above" the temporary hacks section, if possible. It makes it more readable IMO - all the "official" properties go together, and then the "hacks" at the end. #Resolved
| <!-- | ||
| *********************************************************************************************** | ||
| Microsoft.NETCore.Sdk.targets | ||
| netstandard1.0/Microsoft.NETCore.Sdk.targets |
There was a problem hiding this comment.
This is sort of odd to me. All the other .targets files don't have a path in this comment.
(honestly, I'm not sure why we need this name here at all...) #Resolved
There was a problem hiding this comment.
I'll just put the name without a path and I'd be fine removing the names altogether, but we can do that separately. I'm trying to follow a convention that doesn't yet exist, but that I'm proposing in dotnet/msbuild#1046 where a package puts its cross-targeting (aka "outer") build participation in build/cross/packagename.targets. But that creates two files of the same name and so I updated the comment to distinguish them. #Resolved
| @@ -0,0 +1,105 @@ | |||
| <!-- | |||
| *********************************************************************************************** | |||
| Microsoft.NETCore.TargetFrameworkInference.props | |||
There was a problem hiding this comment.
The file has .targets as an extension. Which should it be? #Resolved
There was a problem hiding this comment.
It should be targets. Left over from earlier attempt to do this earlier in props phase. #Resolved
| <Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
|
|
||
| <!-- | ||
| Note that this file is only included when $(TargetFramework) is set and so we do not need to check that here. |
There was a problem hiding this comment.
$(TargetFramework) or $(TargetFrameworks)? #ByDesign
There was a problem hiding this comment.
| </Target> | ||
|
|
||
| <!-- | ||
| Apply the same defaults as common targets now since we're rnning before them, but need to respect defaults |
| if (nearestNuGetFramework == null) | ||
| { | ||
| // TODO: localize: https://github.com/dotnet/sdk/issues/33 | ||
| Log.LogError($"Project has no no target framework compatible with '{ReferringTargetFramework}'"); |
There was a problem hiding this comment.
I think this may be confusing which project this error is referring to.
Looking at the code it looks like this would be one of your dependencies right? Does msbuild give you any nice output that helps clear this up? #Resolved
| </MSBuild> | ||
| </Target> | ||
|
|
||
| <Target Name="Clean" DependsOnTargets="_SetCleanInnerTarget;Build" /> |
There was a problem hiding this comment.
Normally the "Clean" target doesn't do a "Build". #Resolved
There was a problem hiding this comment.
Maybe the "Build" target should be renamed here, as I find it confusing reusing "Build" to do things that are not "Build".
In reply to: 79678083 [](ancestors = 79678083)
There was a problem hiding this comment.
Agree. We should probably call it something like CallInnerBuild or something like that to distinguish it from the actual Build target. #Resolved
There was a problem hiding this comment.
I'll factor it for clarity. I want to preserve that msbuild /p:InnerTargets=x;y;z will do the inner build of x, y, and z. I can do that without actually making build the worker though by making build use a worker too. #Resolved
| Log.LogError($"Project has no no target framework compatible with '{ReferringTargetFramework}'"); | ||
| } | ||
|
|
||
| NearestTargetFramework = PossibleTargetFrameworks[possibleNuGetFrameworks.IndexOf(nearestNuGetFramework)]; |
There was a problem hiding this comment.
What is the reason for indexing here rather than just returning nearestNuGetFramework ? #Resolved
There was a problem hiding this comment.
The reason is that we need to preserve the spelling of target framework. We guarantee that whatever spelling you use in
There was a problem hiding this comment.
I see this makes sense now. #Resolved
| <Import Condition="'$(TargetFramework)' != ''" | ||
| Project="$(MSBuildThisFileDirectory)Microsoft.NETCore.TargetFrameworkInference.targets" /> | ||
|
|
||
| </Project> |
| <TargetFramework Include="$(TargetFrameworks)" /> | ||
| </ItemGroup> | ||
|
|
||
| <Target Name="Build" Returns="@(InnerOutput)"> |
There was a problem hiding this comment.
Maybe just a comment that this is the outer build? #Resolved
|
|
||
| <UsingTask TaskName="GetNearestTargetFramework" AssemblyFile="$(MicrosoftNETCoreBuildTasksAssembly)" /> | ||
|
|
||
| <Target Name="GetTargetFrameworkProperties" Returns="TargetFramework=$(NearestTargetFramework)"> |
There was a problem hiding this comment.
How does this Target get invoked? I don't see it called. #Resolved
There was a problem hiding this comment.
I added this to common targets so that any project can reference a cross-targeted project:
https://github.com/Microsoft/msbuild/blob/e7019886b3fd520b547a7353d78d106d72a4b828/src/XMakeTasks/Microsoft.Common.CurrentVersion.targets#L1494
I'll copy some comments over to make it clear when seeing it on this side too.
#Resolved
|
|
| <!-- https://github.com/dotnet/sdk/issues/145 --> | ||
| <!-- ================================================================================== --> | ||
| <ItemGroup> | ||
| <TargetFramework Include="$(TargetFrameworks)" /> |
There was a problem hiding this comment.
Users may have items called TargetFramework. Can we name this item _TargetFramework or something like that so it's less likely to conflict? #Resolved
There was a problem hiding this comment.
Also should it move into the Build target to scope the item to that target? #Resolved
| if (nearestNuGetFramework == null) | ||
| { | ||
| // TODO: localize: https://github.com/dotnet/sdk/issues/33 | ||
| Log.LogError($"Project has no no target framework compatible with '{ReferringTargetFramework}'"); |
There was a problem hiding this comment.
Should probably return "false" here instead of "true" below. #Resolved
There was a problem hiding this comment.
Or even worse - since nearestNuGetFramework is null, you'll get an IndexOutOfRange exception on the indexer when passing in -1.
In reply to: 79713556 [](ancestors = 79713556)
There was a problem hiding this comment.
Oops. #Resolved
There was a problem hiding this comment.
Style recommendation: never return true or false from within a task. Instead, always return Log.HasLoggedErrors.
It's intensely annoying to debug builds that have failed but emitted no errors, and fairly annoying to go the other way. #Resolved
There was a problem hiding this comment.
I've changed the final return true, but the early false exits are by design and easy to prove Log.HasLoggedErrors is false. I'd like to leave that. #Resolved
|
@dotnet-bot test this please (infrastructure issue) #Closed |
|
@Sridhar-MS I changed OnlyHaveFiles to be recursive and updated kitchen sink test to expect satellites. I needed this to be able to list outputs from more than one framework for cross-targeting. I am now seeing the files missing on Linux. Is there an issue with satellites on Linux? |
|
Looks like #146 which is adding deliberate test coverage for satellites is also failing to find them on linux. |
|
@nguerrera Yup. I am debugging that right now. ReferenceCopyLocalPaths item group is not populated with reference project satellite assemblies on Linux. |
More sophisticated scenarios involving P2P and other verbs will require upstream changes.
|
@Sridhar-MS OK, good luck. ;) I've worked around it by making recursive OnlyHaveFiles optional. This should also eliminate conflicts with your change. |
| <Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
| <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" /> | ||
| <PropertyGroup> | ||
| <Version>42.43.44.45-alpha</Version> |
| @@ -0,0 +1,16 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
| <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" /> | |||
| .Pass(); | ||
|
|
||
| var outputDirectory = buildCommand.GetOutputDirectory(); | ||
| var targetFrameworks = new[] { "netstandard1.4", "netstandard1.5" }; |
There was a problem hiding this comment.
This variable doesn't appear to be used.
Initial implementation of cross-targeting builds.
I'm now working on automated tests, but I know a lot of folks are eager to get these bits, so starting the review now.
Fix #69
Fix #30
Fix dotnet/project-system#380
@srivatsn @eerhardt @rainersigwald @cdmihai @dotnet/project-system