-
Notifications
You must be signed in to change notification settings - Fork 69
Conversation
88abeff
to
cddc984
Compare
<Message Text="============ Done building $(RepositoryToBuild) ============" Importance="High" /> | ||
</Target> | ||
|
||
<Target Name="_PinVersions"> |
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.
Summary of what we're doing here: prior to building a repository:
- We look at the restore graph spec to determine packages with floating versions
- Look at
artifacts/build/*.nupkg and
.deps/build/*.nupkgto determine if we have a package that has the same
{Major.Minor.Build}` number as the floated version - Pin the build if we found something in either of the two packages. The resulting file looks like this:
<Project>
<ItemGroup>
<PackageReference Update="Microsoft.AspNetCore.Http.Abstractions" Version="1.2.0-preview1-t0041a40df" Condition="'$(TargetFramework)'=='net451'" />
<PackageReference Update="Microsoft.AspNetCore.Http.Extensions" Version="1.2.0-preview1-t0041a40df" Condition="'$(TargetFramework)'=='net451'" />
<PackageReference Update="Microsoft.AspNetCore.WebUtilities" Version="1.2.0-preview1-t0041a40df" Condition="'$(TargetFramework)'=='net451'" />
<PackageReference Update="Microsoft.AspNetCore.Http.Abstractions" Version="1.2.0-preview1-t0041a40df" Condition="'$(TargetFramework)'=='netstandard1.3'" />
<PackageReference Update="Microsoft.AspNetCore.Http.Extensions" Version="1.2.0-preview1-t0041a40df" Condition="'$(TargetFramework)'=='netstandard1.3'" />
<PackageReference Update="Microsoft.AspNetCore.WebUtilities" Version="1.2.0-preview1-t0041a40df" Condition="'$(TargetFramework)'=='netstandard1.3'" />
</ItemGroup>
</Project>
- We drop this file in the project's obj directory with the right naming so that the sdk's auto include picks it up.
This removes the need for us to juggle around with the feeds to produce a coherent build. It also works around issues like the one Kestrel hit the other day where a higher version package (that we hadn't mirrored) ended up on NuGet.
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.
Could we take this one step farther and replace the PackageReference with a ProjectReference?
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.
Could we try that as a follow up? I wanted to keep the Update
as simple as possible for now.
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.
Yeah, I should have been clearer. This is okay for now. Was just wondering if you had looked into ProjectReference. At one point I played with generating an MSBuild file in obj/
that removed PackageReference and added ProjectReference...but I ran into lingering issues in Package vs Project precedence in ResolveAssemblyReferences.
build/RepositoryBuild.targets
Outdated
<Message Text="============ Building $(RepositoryToBuild) ============" Importance="High" /> | ||
<Exec | ||
Command="./$(BuildScriptToExecute) $(_RepositoryBuildTargets) /p:BuildNumber=$(BuildNumber) /p:Configuration=$(Configuration)" | ||
IgnoreStandardErrorWarningFormat="true" |
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.
For a full build, MSBuild takes super long to collate all our warnings at the end of the build. aspnet/BuildTools#190 might help, but there's a plethora of warning MSB3277: Found conflicts between different versions of the same dependent assembly that could not be resolved.
that I'm not sure we are doing anything about. Turning this off causes us to lose colorization, but I think it's an acceptable cost for faster builds.
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 might have been completely unrelated. I think I ran in to this: dotnet/msbuild#1808 (comment)
build/repo.targets
Outdated
<MSBuild Projects="$(MSBuildProjectFullPath)" | ||
Targets="Sake" | ||
Properties="SakeTargets=$(_SakeTargets);RepositoryRoot=$(RepositoryRoot)" /> | ||
<Target Name="BuildRepositories" |
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 always attempts to produce a coherent build from the list of cloned repositories. Doing this includes fiddling around with repo's NuGet.configs + pinning package versions. We could add a different (default?) target that does what .\build
used to do with sake - i.e build the repositories in sequence (ever since we broke build install
(aspnet/KoreBuild#17).
That said, it might be simpler to say this repo is primarily a way for our build system to co-ordinate builds rather than for users to build all of AspNet. I'm not sure there's a lot of value in doing this. Thoughts @davidfowl ?
build/repo.targets
Outdated
<MSBuild | ||
Projects="$(MSBuildThisFileDirectory)RepositoryBuild.targets" | ||
Targets="BuildRepositories" | ||
Properties=" |
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.
Is there a saner way to do this?
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.
You can build up a list of properties incrementally.
https://github.com/aspnet/KoreBuild/blob/dev/build/targets/KoreBuild.SolutionBuild.targets#L148-L151
|
||
namespace BuildGraph | ||
{ | ||
public class DGMLFormatter : GraphFormatter |
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.
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.
Any C# code we need to review in detail? Or was the build train code already reviewed thoroughly?
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.
@anurse would know. I know a couple of folks including me looked at it at some point, but I'm not sure how thorough it was.
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.
I'd take a look at the code. BuildTrain didn't really get any eyes because it was very prototypey and then kinda just got abandoned :)
tools/BuildGraph/Project.cs
Outdated
{ | ||
var project = new Project(name) | ||
{ | ||
// PackageReferences = MSBuildEval.GetPackageReferences(path), |
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.
Will remove
cddc984
to
a39f81d
Compare
a39f81d
to
27581e4
Compare
build/RepositoryBuild.targets
Outdated
<Target Name="_PinVersions"> | ||
<PropertyGroup> | ||
<PinToolBinary>$(RepositoryRoot)tools\PinVersions\bin\$(Configuration)\netcoreapp1.1\PinVersions.dll</PinToolBinary> | ||
<PinVersionArgs>$(DotNetPath) $(PinToolBinary) --graph-specs-root "$(_RestoreGraphSpecsDirectory) " -s "$(BuildDir) " "$(BuildRepositoryRoot) "</PinVersionArgs> |
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.
build/RepositoryBuild.targets
Outdated
|
||
<Target Name="_BuildRepository" DependsOnTargets="_PinVersions"> | ||
<PropertyGroup> | ||
<BuildScriptToExecute Condition="'$(OS)'!='Windows_NT'">build.sh</BuildScriptToExecute> |
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.
Instead of MSBuild => shell script => MSBuild, have you considered going straight to using MSBuild? KoreBuild is designed to key all locations off the RepositoryRoot
property.
<MSBuild Projects="$(MSBuildProjectFullPath)" Properties="RepositoryRoot=$(BuildRepositoryRoot)" />
This avoids the pre-flight restore N+1 times for building N repositories, takes advantage of using the MSBuild already loaded in memory, and potentially avoids some thrashing by letting MSBuild orchestrate the entire build top to bottom.
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.
We could do that. My only mild concern was if the repos had out-of-sync versions of KoreBuild (like we did during the Tooling migration). Maybe that's an issue we can deal with when it arises.
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.
I think this should totally be the end goal. If we can do it now that'd be great, but there may be some other vestigial things in the build system that prevent it right now. If we can't do it now though, let's file an issue to track it because I think Nate's right that it'll be significantly faster.
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.
Maybe that's an issue we can deal with when it arises.
That's a good concern. I was actually just thinking about that. I don't expect we will hit this soon. In the long run, I'm hoping we can do something like aspnet/KoreBuild#196. In the short run, we could fall back to invoking build.cmd if we need to.
build/RepositoryBuild.targets
Outdated
|
||
<Copy | ||
SourceFiles="@(ArtifactsToCopy)" | ||
DestinationFolder="$(BuildDir)" /> |
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.
You can reduce disk usage by overriding the BuildDir
setting for each repo so that it copies the packages into the Universe artifact folder directly.
build/repo.targets
Outdated
<Repository Remove="@(RepositoriesToExclude)" /> | ||
</ItemGroup> | ||
|
||
<Warning Text="KOREBUILD_REPOSITORY_EXCLUDE AND KOREBUILD_REPOSITORY_INCLUDE are specified." |
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.
Error? What's the problem 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.
I think you want to pick one or the other. It's likely a bad configuration when both are specified. I could make this an Error
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.
Yeah, let's make it an error. Sometimes the only way to find bad configs is to force them to fail.
build/repo.targets
Outdated
</_CloneRepository> | ||
</ItemGroup> | ||
|
||
<RemoveDir Directories="$(_CloneRepositoryRoot)" Condition="Exists('$(_CloneRepositoryRoot)')" /> |
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.
Can we not do this? When doing cross-repo work, I work inside the Universe folder. It's nice to repeatedly run universe commands without it deleting all my work.
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.
I can move this to Clean.
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.
Awesome, thanks!
build/repo.targets
Outdated
SourceFiles="$(MSBuildThisFileDirectory)Repositories.props" | ||
DestinationFiles="$(RepositoryFileWithCommit)" /> | ||
|
||
<Exec |
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.
Did you consider using MSBuild instead of a console tool to do this? IIUC what the AddCommitInfo file does, you can probably reduce this to something like:
<GetGitCommitInfo WorkingDirectory="$(_CloneRepositoryRoot)">
<Output TaskParameter="CommitHash" PropertyName="_Hash" />
</GetGitCommitInfo>
<XmlPoke2 XmlInputPath="$(RepositoryFileWithCommit)"
Query="//Repository[@Include='$(RepoName)']/@Commit" Value="$(_Hash)" />
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.
I was under the impression that XmlPoke(2)
can't add new attributes.
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 you generate "RepositoryFileWithCommit", you could add an empty Commit attribute.
tools/AddCommitInfo/Program.cs
Outdated
|
||
private static string ReadCommitHash(string repositoryPath) | ||
{ | ||
// Based on https://github.com/aspnet/BuildTools/blob/dev/src/Internal.AspNetCore.BuildTools.Tasks/GetGitCommitInfo.cs |
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.
I'm against copy + pasting code from other repos. If you don't my suggestion above (implementing this tool in MSbuild instead), let's instead make this tool depend on Internal.AspNetCore.BuildTools.Tasks directly. We can abstract what GetGitCommitInfo to make it more usable if necessary.
tools/shared/DotNetMuxer.cs
Outdated
using System.IO; | ||
using System.Runtime.InteropServices; | ||
|
||
// Copy of code from https://github.com/aspnet/DotNetTools/blob/047e4a8533bbcdf22831c40dd9d9aaf0c80d1953/shared/DotNetMuxer.cs |
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.
Ahhh! We need to put this in a common place. dotnet/extensions#173
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.
I could reference CLI.Utils here instead and use their version of this type. How about that?
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.
Yeah, let's do that for now.
I think this is a great step forward. I'm in favor of the work, but I think we'll get even more benefit from the MSBuild upgrade to make our build system MSbuild top-to-bottom. That means instead of 'Exec'-ing to dotnet-run, let's make those tools MSBuild tasks. The benefits we get:
|
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.
LGTM but I haven't been able to look in depth.
build/Repositories.props
Outdated
<Repository Include="Testing" /> | ||
<Repository Include="WebSockets" /> | ||
</ItemGroup> | ||
</Project> |
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.
build/RepositoryBuild.targets
Outdated
|
||
<Target Name="_BuildRepository" DependsOnTargets="_PinVersions"> | ||
<PropertyGroup> | ||
<BuildScriptToExecute Condition="'$(OS)'!='Windows_NT'">build.sh</BuildScriptToExecute> |
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.
I think this should totally be the end goal. If we can do it now that'd be great, but there may be some other vestigial things in the build system that prevent it right now. If we can't do it now though, let's file an issue to track it because I think Nate's right that it'll be significantly faster.
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.
Looks good enough for now. I don't want to hold up progress on getting Universe builds onto MSBuild.
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.
Agree w/ @natemcmaster. Let's get this in and improve as-needed later.
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "shared", "shared", "{085280EC-7055-426A-BF9C-1B692B9599AB}" | ||
ProjectSection(SolutionItems) = preProject | ||
tools\shared\DependencyGraphSpecProvider.cs = tools\shared\DependencyGraphSpecProvider.cs |
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.
Think I noticed @(Compile)
items don't show up in projects. If that's the reason this is here, please file a bug on the project system.
Projects="@(BatchedRepository)" | ||
BuildInParallel="$(BatchBuilds)" | ||
Targets="_BuildRepository" | ||
Properties="BuildGroup=%(BatchedRepository.BuildGroup)" /> |
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.
What reads the $(BuildGroup)
property?
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's used to batch the builds. Essentially the GroupBy
argument.
|
||
namespace BuildGraph | ||
{ | ||
public class DGMLFormatter : GraphFormatter |
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.
Any C# code we need to review in detail? Or was the build train code already reviewed thoroughly?
No description provided.