Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port MSBuild targets from Korebuild into an SDK package #145

Merged
merged 1 commit into from
Jan 11, 2017

Conversation

natemcmaster
Copy link
Contributor

Fixes the requirement for running 'build initialize' before opening aspnet repos in VS 2017.

Changes:
Instead of our repos importing MSBuild targets directly from the korebuild download folder, we will use NuGet to distribute these shared properties and targets.

More context:
MSBuild is working on adding first-class support for distributing SDKs via NuGet. (See dotnet/msbuild#1493). When this is in, we may be able to use that instead of a PackageReference.

cc @Eilon for naming stuff
cc @pranavkm for implementation review

@@ -0,0 +1,27 @@
; EditorConfig to support per-solution formatting.
Copy link
Member

Choose a reason for hiding this comment

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

Remove this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -0,0 +1,8 @@
<!--
WARNING: These targets are indented for building Microsoft's ASP.NET Core repos, and is not intended
Copy link
Member

Choose a reason for hiding this comment

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

Is indented supposed to be intended

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops. yeah.

@@ -0,0 +1,5 @@
{
"sdk": {
"version": "1.0.0-preview4-004233"
Copy link
Member

Choose a reason for hiding this comment

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

global.json in an msbuild project?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup. global.json also used by the dotnet.exe muxer to determine SDK version.

<version>1.0.0-$versionsuffix$</version>
<authors>Microsoft</authors>
<description>Build targets and customizations to Microsoft.NET.Sdk</description>
<!-- TODO use contentFiles for cs files-->
Copy link
Member

Choose a reason for hiding this comment

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

This work item is tracked somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's part of aspnet/KoreBuild#150

// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

[assembly: System.Reflection.AssemblyMetadata("Serviceable", "True")]
Copy link
Member

Choose a reason for hiding this comment

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

Is this needed? There's not supposed to be a DLL in this project, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is not .dll for the SDK. This file is added to the <Compile> items.

Copy link
Member

Choose a reason for hiding this comment

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

Is it needed? Oh wait, is this for all our regular projects to consume (i.e. we can delete this from all the other repos)? Or is this actually compiled into a DLL right here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right. This is for regular projects. we started deleting AssemblyInfo.cs from our projects because all of its content is generated by Microsoft.NET.SDK (with the exception of the this serviceable attrbute).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

<BuildNumber Condition="'$(BuildNumber)'==''">$(_SecondBasedTimeStamp)</BuildNumber>
<VersionSuffix Condition="'$(VersionSuffix)'!='' AND '$(BuildNumber)' != ''">$(VersionSuffix)-$(BuildNumber)</VersionSuffix>
<VersionSuffix Condition="'$(VersionSuffix)'==''">$(BuildNumber)</VersionSuffix>
<PackWithoutBuildNumber Condition="'$(PackWithoutBuildNumber)'==''">false</PackWithoutBuildNumber>
Copy link
Member

Choose a reason for hiding this comment

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

Is the CI setup to use this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not yet. At the moment, CI unzips *.nupkg files, edits the nuspec xml, and re-zips with the timestamp-free version. This piece here will let us set the version numbers correctly upfront.

Copy link
Contributor

Choose a reason for hiding this comment

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

We're likely not going to do that. We almost never want to publish timestamp free builds until they're verified which this allows. But leaving this in doesn't hurt.

#pack-sdk target='package'
@{
var buildNumber = E("BuildNumber") ?? BuildNumber;
NugetPack(E("KOREBUILD_NUGET_EXE") ?? ".build/NuGet.exe",
Copy link
Member

Choose a reason for hiding this comment

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

nit: extra space

@BrennanConroy
Copy link
Member

🚢 🇮🇹 after minor thing(s)

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="AspNetVNext" value="https://www.myget.org/F/aspnetcidev/api/v3/index.json" />
<add key="AspNetVNext" value="https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json" />
Copy link
Contributor

Choose a reason for hiding this comment

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

👏

Copy link
Contributor

Choose a reason for hiding this comment

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

<add key="AspNetCore" value="https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json" /> to be consistent with other repos. That said, does this actually need to reference our dev feed? Can we get away pointing to aspnet-master or something like that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, it looks like this project doesn't need anything from the nightly feed. I'll just remove altogether.

@@ -0,0 +1,49 @@
<!--
WARNING: These targets are indented for building Microsoft's ASP.NET Core repos, and is not intended
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: These targets are indented intended for

Create second-based build number for local builds.
635556672000000000 is Jan 1, 2015.
-->
<_SecondBasedTimeStamp>$([System.DateTime]::UtcNow.Subtract($([System.DateTime]::FromBinary(635556672000000000))).TotalSeconds.ToString("F0"))</_SecondBasedTimeStamp>
Copy link
Contributor

Choose a reason for hiding this comment

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

Does <_Timestamp>$([System.DateTime]::UtcNow.Ticks.ToString("x").PadLeft(20, '0')</_Timestamp> work? I know they removed the special version length restriction in recent builds of NuGet, so we could simplify this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Might work. But I still prefer the shorter version.

Plus, it's possible some might build with NuGet 4.0 but need to install to project.json which uses NuGet 3.5. I'm not confident the version-length restriction is fixed there.

<_SecondBasedTimeStamp>t$([System.Int64]::Parse($(_SecondBasedTimeStamp)).ToString("x9"))</_SecondBasedTimeStamp>

<!-- for aspnet CI -->
<BuildNumber Condition="'$(BuildNumber)'==''">$(KOREBUILD_BUILD_NUMBER)</BuildNumber>
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's just modify the CI to specify /p:BuildNumber=%build.number% and remove references to KoreBuild here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Too early. We can do this when we migrate everything to MSbuild.

<BuildNumber Condition="'$(BuildNumber)'==''">$(_SecondBasedTimeStamp)</BuildNumber>
<VersionSuffix Condition="'$(VersionSuffix)'!='' AND '$(BuildNumber)' != ''">$(VersionSuffix)-$(BuildNumber)</VersionSuffix>
<VersionSuffix Condition="'$(VersionSuffix)'==''">$(BuildNumber)</VersionSuffix>
<PackWithoutBuildNumber Condition="'$(PackWithoutBuildNumber)'==''">false</PackWithoutBuildNumber>
Copy link
Contributor

Choose a reason for hiding this comment

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

We're likely not going to do that. We almost never want to publish timestamp free builds until they're verified which this allows. But leaving this in doesn't hurt.

<_PackageReferences Include="@(_ResolvedFloatingVersion)" Condition="'%(Identity)'=='%(_ResolvedFloatingVersion.ResolvedName)'" />
</ItemGroup>

<Message Importance="Normal" Text="Proj: %(_ProjectReferences.FileName) %(_ProjectReferences.PackageVersion)" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Debugging code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, but it doesn't hurt to leave it. Doesn't show up by default in log output.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe make Importance='Low"?

</PropertyGroup>
<!-- end workaround -->

<!-- workaround https://github.com/NuGet/Home/issues/4063 -->
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there an RC3 build we could use that addresses these workarounds?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not yet. We're still stuck on RC.2 because of blocking issues.

"src/Internal.AspNetCore.Sdk/Internal.AspNetCore.Sdk.nuspec",
BUILD_DIR,
"-Verbosity Detailed"
+ " -Properties versionsuffix=alpha-" + buildNumber);
Copy link
Contributor

Choose a reason for hiding this comment

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

Weird formatting. Can you move this to the previous line?


<PropertyGroup>
<!-- these imports substitute for a package reference to Internal.AspNetCore.Sdk -->
<CustomBeforeMicrosoftCommonProps>$(MSBuildThisFileDirectory)..\src\Internal.AspNetCore.Sdk\build\Internal.AspNetCore.Sdk.props</CustomBeforeMicrosoftCommonProps>
Copy link
Contributor

Choose a reason for hiding this comment

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

<_SdkProjectDirectory>$(MSBuildThisFileDirectory)..\src\Internal.AspNetCore.Sdk</_SdkProjectDirectory> and reuse. Probably better if we do

$([MSBuild]::GetDirectoryNameOfFileAbove($(MsBuildThisFileDirectory), NuGet.config)) since it makes multiple levels of folder hierarchy possible without hardcoding the relative directory structure

@{
var buildNumber = E("BuildNumber") ?? BuildNumber;
NugetPack(E("KOREBUILD_NUGET_EXE") ?? ".build/NuGet.exe",
"src/Internal.AspNetCore.Sdk/Internal.AspNetCore.Sdk.nuspec",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why can't we dotnet pack the csproj?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no csproj.

@natemcmaster natemcmaster merged commit efa9ff1 into dev Jan 11, 2017
natemcmaster pushed a commit to aspnet/PlatformAbstractions that referenced this pull request Jan 11, 2017
@natemcmaster natemcmaster deleted the namc/common-build branch February 15, 2017 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants