Skip to content
This repository has been archived by the owner on May 21, 2019. It is now read-only.

Build the sln file instead of individual project files #159

Merged
merged 2 commits into from
Feb 9, 2017

Conversation

natemcmaster
Copy link
Contributor

Perf improvement: only builds each project once during the 'build-compile' target.

}

if (projectGlobs.Any())
foreach (var sln in Files.Include(Path.Combine(BASE_DIR, "*.sln")))
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we just build $repoName.sln - seems like a convention all our repos follow. We could throw an error if there happen to be more than one sln.

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, that could be fine. I know off the top of my head that Diagnostics has DiagnosticPages.sln. Are there others?

Copy link
Contributor

Choose a reason for hiding this comment

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

HttpSysServer still has WebListener.sln though I think WebListener as a repo name will redirect properly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We also need to change that rename in aspnet/Universe's list of repos.

Copy link
Contributor

Choose a reason for hiding this comment

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

We could throw an error if there happen to be more than one sln.

Meant to say we could throw an error to say we couldn't find the sln if we don't find it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only problematic thing is...how do you determine "$repoName"? We can't use directory name as it's not guaranteed....

Copy link
Contributor

Choose a reason for hiding this comment

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

That's true. I guess we should get Mvc to move the second sln (the NoFun one) out of the repo root as part of the migration. We'll switch to calling dotnet build and have it fail in the non-common cases.

FYI @NTaylorMullen

Copy link
Contributor

Choose a reason for hiding this comment

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

Bummer, was working around some issues with having multiple sln's in Mvc's migrated makefile. Could we take the approach of having a parameter that we can set to override the default sln name?. It'd be a shame to hide sln's that we actually use from users who clone our repos.

Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of a parameter, we could build a well known file (build.proj?) if it's present. We can't run dotnet build regardless.

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 this problem can be solved by the work Pranav is doing on #158. The default Korebuild build step could include:

<SolutionsToBuild Include="$(RepoRoot)\*.sln" />

MVC and other repos could customize by adding exclusions to the build/repo.targets file:

<SolutionsToBuild Remove="$(RepoRoot)\Mvc.NoFun.sln" />

@natemcmaster
Copy link
Contributor Author

natemcmaster commented Feb 3, 2017

Almost there: something in Korebuild is attempting to use obj/*.dll...I think.

CSC : error CS2012: Cannot open 'C:\dev\Universe\DependencyInjection\src\Microsoft.Extensions.DependencyInjection\obj\Debug\netstandard1.1\Microsoft.Extensions.DependencyInjection.dll' for writing -- 'The process cannot access the file 'C:\dev\Universe\DependencyInjection\src\Microsoft.Extensions.DependencyInjection\obj\Debug\netstandard1.1\Microsoft.Extensions.DependencyInjection.dll' because it is being used by another process.' [C:\dev\Universe\DependencyInjection\src\Microsoft.Extensions.DependencyInjection\Microsoft.Extensions.DependencyInjection.csproj] [C:\dev\Universe\DependencyInjection.build\targets\makefile.proj]

Doesn't happen when you call "dotnet build" on the solution, w/o korebuild

@natemcmaster
Copy link
Contributor Author

Nvm, it's dotnet/sdk. dotnet/sdk#739

</PropertyGroup>

<Exec
Command="$(SakeExecutable) -I $(KoreBuildDirectory)shade -f $(MakeFilePath) $(ShadeTarget)"
Command="$(SakeExecutable) -I &quot;$(MSBuildThisFileDirectory)../shade&quot; -f $(MakeFilePath) $(SakeTargets)"
Copy link
Contributor

Choose a reason for hiding this comment

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

👏

@@ -1,6 +1,7 @@
<Project>
<PropertyGroup>
<BuildDir>$(RepositoryRoot)\build</BuildDir>
<ArtifactsDir>$(BuildDir)\artifacts</ArtifactsDir>
<RepositoryRoot Condition="'$(RepositoryRoot)'==''">$(MSBuildThisFileDirectory)..\..\</RepositoryRoot>
Copy link
Member

Choose a reason for hiding this comment

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

This location can easily be incorrect, especially in (nested) test directories. Why isn't this using $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), "$(Repository).sln") or something similar?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

MSBuildThisFileDirectory refers to the location of .build/targets/common.props, not the location of test projects. This value isn't affect by nested test directories.


<Target Name="Clean" />
<ItemGroup>
<SolutionsToBuild Include="$(RepositoryRoot)\*.sln" />
Copy link
Member

Choose a reason for hiding this comment

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

This won't work well at least for Mvc. Why not $(RepositoryRoot)\$(RepoName).sln?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The goal here is to make the default case work, which is that we have one sln per repo. MVC and any other solution that has multiple solutions would put something like this in to build/repo.targets:

<SolutionsToBuild Remove="Mvc.NoFun.sln" />

We don't have a good way to determine "RepoName" :-/ as the folder name containing the source code is not guaranteed to match the sln name.

{
Dotnet("msbuild /nologo"
+ " \"" + Path.Combine(Directory.GetCurrentDirectory(), ".build/targets/makefile.proj") + "\""
+ " \"/p:LifecycleType=Standard;Configuration=" + E("Configuration") + "\""
Copy link
Member

Choose a reason for hiding this comment

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

With changes to build/targets/makefile.proj, does this command-line lifecycle choice still work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For now, yes, you can still express build verify and build --for-ci build-compile etc.

@natemcmaster natemcmaster force-pushed the namc/incremental branch 2 times, most recently from af694f7 to d7c5079 Compare February 8, 2017 22:19
@natemcmaster
Copy link
Contributor Author

🆙 📅 Removing the [blocked] label. The race condition in solution builds has been fixed.

@natemcmaster
Copy link
Contributor Author

I added two changes to be aware of.

(1) the tool dependencies (Sake, NuGetPackageVerifier, and NETFrameworkReferenceAssemblies) restore into the regular nuget cache instead of into the .build folder
(2) Update to CLI 1.0.0-rc4-004777

We'll need to update other repos. Any project that has multiple *.sln files or has projects in the solution file that doen't build with dotnet-CLI will need to be updated. Razor, MVC, and possibly others.

@natemcmaster
Copy link
Contributor Author

cc @pakrym

@pakrym
Copy link
Contributor

pakrym commented Feb 9, 2017

Wouldn't calling pack on each project try to rebuild everything again?

@natemcmaster
Copy link
Contributor Author

At the moment yes it will build twice. This is an incremental step towards eliminating the Sake lifecycle. Some of our repos have custom packaging steps that we need to port to MSBuild.

This has the advantage of only rebuilding projects once during the pack phase. MSBuild will batch the builds during pack.

In a follow up PR, we can move even more into MSBuild so each project should only compile once per build.cmd run.

@pakrym
Copy link
Contributor

pakrym commented Feb 9, 2017

👍 LGTM

@natemcmaster natemcmaster merged commit 6616302 into feature/msbuild Feb 9, 2017
@natemcmaster natemcmaster deleted the namc/incremental branch February 9, 2017 22:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants