-
Notifications
You must be signed in to change notification settings - Fork 789
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build and package fsc using .NET Core Sdk
- add helper script to install .NET Core Sdk (only if needed) - build `Fsc.netcore.fspro with `fsc-proto` - publish Fsc using .NET Core Sdk as framework dependent app - create `Microsoft.FSharp.Compiler.Sdk.netcore` package - add build script using `dotnet msbuild` - run when `netcoresdk` arg is passed to build script (`build.cmd`) - add end to end tests to check created package - add examples of .net core sdk projects (lib/console)
- Loading branch information
1 parent
877aed4
commit 7538cd1
Showing
39 changed files
with
1,281 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.0.0-preview4-004233 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<Project ToolsVersion="15.0" InitialTargets="CheckPrereqs" DefaultTargets="All"> | ||
|
||
<Target Name="Init"> | ||
<!-- Define global properties --> | ||
|
||
<PropertyGroup> | ||
<RepoRoot>$(MSBuildThisFileDirectory)</RepoRoot> | ||
<NuGetPackageRoot>$(RepoRoot)/packages</NuGetPackageRoot> | ||
</PropertyGroup> | ||
</Target> | ||
|
||
<Import Project="build/CheckPrereqs.proj" /> | ||
<Import Project="build/Prepare.proj" /> | ||
<Import Project="build/Compile.proj" /> | ||
<Import Project="build/Package.proj" /> | ||
<Import Project="build/Test.E2E.proj" /> | ||
|
||
<Target Name="All" | ||
DependsOnTargets="Prepare; | ||
Compile; | ||
Package; | ||
TestE2E;" /> | ||
<Target Name="Clean" | ||
DependsOnTargets="CleanSrcLockFiles; | ||
CleanCompile; | ||
CleanPackage; | ||
CleanTestE2E;" /> | ||
|
||
<!-- | ||
# MAIN TARGETS | ||
- `CheckPrereqs` check prerequisites, always runs as the first target | ||
- `Prepare` restore projects | ||
- `Compile` build all projects | ||
- `Package` create the nuget packages | ||
- `TestE2E` run End to End tests, using built nupkgs | ||
- `Clean` remove all build artifacts | ||
Build pipeline (target `All`) is: | ||
CheckPrereqs -> Prepare -> Compile -> Package -> TestE2E | ||
# PARAMETERS | ||
these can be passed as msbuild properties (/p) or env var | ||
If not set, defaults are used. | ||
| Name | Description | Example | | ||
|~~~~~~~~~~~~~~~~~~~~~~|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| | ||
| PackageVersion | Full version to use for nupkgs | "1.0.0-rc-170124" | | ||
| Packages | List of nupkgs to generate, by default all. | "Microsoft.FSharp.Compiler.Sdk.netcore" | | ||
| NupkgOutputDirectory | Output Dir of generated nupkgs | A directory full path | | ||
# TARGETS | ||
- `RestoreSrcPackages` restore the /src projects | ||
- `CleanSrcLockFiles` clean the nuget restore lock files (so `RestoreSrcPackages` can be run again) | ||
- `BuildFsc` compile fsc | ||
- `PublishFsc` publish fsc as framework dependent deployment (ready for `dotnet /path/to/fsc.dll`) | ||
- `RunPackageTests` test the built packages in real projects E2E | ||
- the `RestoreTestPackages` and `CleanTestLockFiles` manage the restore of test projects | ||
--> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<Project ToolsVersion="15.0"> | ||
|
||
<Target Name="CheckPrereqs"> | ||
<!-- Check .NET Core SDK is avaiable in PATH --> | ||
|
||
<Exec Command="dotnet --version" ConsoleToMSBuild="true"> | ||
<Output TaskParameter="ConsoleOutput" PropertyName="InstalledDotnetCoreSdkVersion" /> | ||
</Exec> | ||
|
||
<Message Text="Installed sdk version $(InstalledDotnetCoreSdkVersion)" Importance="High" /> | ||
|
||
<!-- Check the .NET Core SDK version is compatible (same branch) with required version --> | ||
<PropertyGroup> | ||
<_ExpectedDotnetCoreSdkBranch>1.0.0-preview4</_ExpectedDotnetCoreSdkBranch> | ||
</PropertyGroup> | ||
|
||
<Error Text="Expected .NET Core Sdk ~$(_ExpectedDotnetCoreSdkBranch) but was $(InstalledDotnetCoreSdkVersion)" | ||
Condition=" !$(InstalledDotnetCoreSdkVersion.StartsWith('$(_ExpectedDotnetCoreSdkBranch)')) " /> | ||
</Target> | ||
|
||
<Target Name="RequireCoreclrBin" | ||
DependsOnTargets="Init"> | ||
<!-- Check the coreclr binaries built with main build script is avaiable --> | ||
<!-- DEFINE $(CoreclrReleaseDir): The directory of coreclr binaries built by main script --> | ||
|
||
<PropertyGroup> | ||
<CoreclrReleaseDir>$(RepoRoot)/$(Configuration)/coreclr/bin</CoreclrReleaseDir> | ||
</PropertyGroup> | ||
|
||
<Error Text="The '$(CoreclrReleaseDir)' is required, build it using `build.cmd coreclr` " | ||
Condition=" !Exists('$(CoreclrReleaseDir)') " /> | ||
</Target> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<Project ToolsVersion="15.0"> | ||
|
||
<Target Name="Compile" | ||
DependsOnTargets="Prepare; | ||
BuildFsc" /> | ||
|
||
<Target Name="BuildFsc" | ||
DependsOnTargets="Init; | ||
RequireCoreclrBin" > <!-- the fsc proj expect the FSharp.Core already built --> | ||
|
||
<Exec Command='dotnet build "$(RepoRoot)/src/fsharp/Fsc/Fsc.netcore.fsproj" -c $(Configuration)' /> | ||
</Target> | ||
|
||
<Target Name="PublishFsc" | ||
DependsOnTargets="Init;RequireCoreclrBin;BuildFsc" > | ||
<!-- Create a framework dependent version of fsc --> | ||
<!-- DEFINE $(FscPublishDirectoryNetCoreApp1_0): The directory who contains the framework dependent version of fsc --> | ||
|
||
<Exec Command='dotnet publish "$(RepoRoot)/src/fsharp/Fsc/Fsc.netcore.fsproj" -c $(Configuration)' /> | ||
|
||
<PropertyGroup> | ||
<FscPublishDirectoryNetCoreApp1_0>$(RepoRoot)/src/fsharp/Fsc/bin/$(Configuration)/netcoreapp1.0/publish</FscPublishDirectoryNetCoreApp1_0> | ||
</PropertyGroup> | ||
|
||
<!-- REMARK: The generated fsc.dll doesnt work yet. | ||
Reuse the fsc.exe already built until it's fixed --> | ||
<Copy SourceFiles="$(CoreclrReleaseDir)/fsc.exe; | ||
$(CoreclrReleaseDir)/fsc.pdb;" | ||
DestinationFiles="$(FscPublishDirectoryNetCoreApp1_0)/fsc.dll; | ||
$(FscPublishDirectoryNetCoreApp1_0)/fsc.pdb;" | ||
OverwriteReadOnlyFiles="true" /> | ||
|
||
</Target> | ||
|
||
<Target Name="CleanCompile" | ||
DependsOnTargets="Init"> | ||
|
||
<RemoveDir Directories="$(RepoRoot)/src/fsharp/Fsc/bin" /> | ||
<RemoveDir Directories="$(RepoRoot)/src/fsharp/Fsc/obj" /> | ||
</Target> | ||
|
||
</Project> |
57 changes: 57 additions & 0 deletions
57
build/Package.Nupkg.Microsoft.FSharp.Compiler.Sdk.netcore.proj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<Project ToolsVersion="15.0"> | ||
|
||
<ItemGroup> | ||
<SetupNugetPackagesDependsOn Include="SetupNugetPackages_MicrosoftFSharpCompilerSdknetcore" /> | ||
</ItemGroup> | ||
|
||
<Target Name="SetupNugetPackages_MicrosoftFSharpCompilerSdknetcore" | ||
Condition=" '$(Packages)' == '' or $(Packages.Contains('Microsoft.FSharp.Compiler.Sdk.netcore'))" | ||
DependsOnTargets="Init;RequireCoreclrBin;PublishFsc" > | ||
<PropertyGroup> | ||
<_PackageProjectDir>$(RepoRoot)/src/fsharp/FSharp.Compiler.Sdk.netcore.nuget</_PackageProjectDir> | ||
<_PackageName>Microsoft.FSharp.Compiler.Sdk.netcore</_PackageName> | ||
</PropertyGroup> | ||
<!-- Specify the 'Microsoft.FSharp.Compiler.Sdk.netcore' nuget package content --> | ||
|
||
<!-- Package content --> | ||
<ItemGroup> | ||
<!-- the published fsc for netcoreapp1.0 --> | ||
<_FscPublishOutputFiles Include="$(FscPublishDirectoryNetCoreApp1_0)/**/*" /> | ||
<_FsharpBuildFiles Include="$(CoreclrReleaseDir)/FSharp.Build.*" /> | ||
<_PackageProjectFiles Include="$(_PackageProjectDir)/**/*" | ||
Exclude="$(_PackageProjectDir)/*.nuspec;$(_PackageProjectDir)/bin/**/*" /> | ||
|
||
<!-- the fsc published (netcoreapp1.0) files --> | ||
<NugetPackageLayout Include="@(_FscPublishOutputFiles)"> | ||
<PackageName>$(_PackageName)</PackageName> | ||
<PackageRelativePath>build/netcoreapp1.0/%(RecursiveDir)%(FileName)%(Extension)</PackageRelativePath> | ||
</NugetPackageLayout> | ||
|
||
<!-- the FSharp.Build assembly who contains msbuild tasks --> | ||
<NugetPackageLayout Include="@(_FsharpBuildFiles)"> | ||
<PackageName>$(_PackageName)</PackageName> | ||
<PackageRelativePath>build/netcoreapp1.0/%(RecursiveDir)%(FileName)%(Extension)</PackageRelativePath> | ||
</NugetPackageLayout> | ||
|
||
<!-- The package content files, except the nuspec --> | ||
<NugetPackageLayout Include="@(_PackageProjectFiles)"> | ||
<PackageName>$(_PackageName)</PackageName> | ||
<PackageRelativePath>%(RecursiveDir)%(FileName)%(Extension)</PackageRelativePath> | ||
</NugetPackageLayout> | ||
</ItemGroup> | ||
|
||
<PropertyGroup> | ||
<PackageVersion Condition="'$(PackageVersion)' == ''" >$(NuGetPerBuildPreReleaseVersion)</PackageVersion> | ||
</PropertyGroup> | ||
|
||
<!-- Package metadata --> | ||
<ItemGroup> | ||
<NugetPackageDef Include="$(_PackageName)"> | ||
<NuspecFile>$(_PackageProjectDir)/$(_PackageName).nuspec</NuspecFile> | ||
<Version>$(PackageVersion)</Version> | ||
</NugetPackageDef> | ||
</ItemGroup> | ||
|
||
</Target> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<Project ToolsVersion="15.0"> | ||
|
||
<Import Project="../src/FSharp.nugets.props" /> | ||
|
||
<!-- Import all nuget package definitions --> | ||
<Import Project="Package.Nupkg.Microsoft.FSharp.Compiler.Sdk.netcore.proj" /> | ||
|
||
<Target Name="Package" | ||
DependsOnTargets="Prepare; | ||
Compile; | ||
GenerateNugetPackages" /> | ||
|
||
<Target Name="SetupNugetPackagesProperties" | ||
DependsOnTargets="Init" > | ||
<!-- Global properties required for nuget packages creation, like output dir and layout dir --> | ||
|
||
<PropertyGroup> | ||
<NupkgOutputDirectory Condition=" '$(NupkgOutputDirectory)' == '' ">$(RepoRoot)/$(Configuration)/artifacts</NupkgOutputDirectory> | ||
<PackagingBuildBasePath>$(RepoRoot)/$(Configuration)/forPackaging</PackagingBuildBasePath> | ||
</PropertyGroup> | ||
</Target> | ||
|
||
<Target Name="SetupNugetPackages" | ||
DependsOnTargets="Init; | ||
SetupNugetPackagesProperties; | ||
@(SetupNugetPackagesDependsOn)" /> | ||
|
||
<Target Name="LayoutNugetPackages" | ||
DependsOnTargets="Init;SetupNugetPackagesProperties;SetupNugetPackages" | ||
Outputs="%(NugetPackageLayout.PackageName)" > | ||
<!-- Create the directory with the content of nuget packages, ready for nuget pack --> | ||
|
||
<PropertyGroup> | ||
<_PackageName>%(NugetPackageLayout.PackageName)</_PackageName> | ||
</PropertyGroup> | ||
|
||
<Copy SourceFiles="%(NugetPackageLayout.Identity)" | ||
Condition=" '%(PackageName)' == '$(_PackageName)' " | ||
DestinationFiles="$(PackagingBuildBasePath)/%(PackageName)/%(PackageRelativePath)" | ||
SkipUnchangedFiles="true" /> | ||
</Target> | ||
|
||
<Target Name="GenerateNugetPackages" | ||
DependsOnTargets="Init;LayoutNugetPackages" | ||
Outputs="$(NupkgDirectory)/%(NugetPackageDef.Identity).%(NugetPackageDef.Version).nupkg" > | ||
<!-- Generate the nuget packages, doing nuget pack of prepared layour dir and setting metadata --> | ||
|
||
<PropertyGroup> | ||
<PackageLicenceUrl Condition="'$(PackageLicenceUrl)' == ''">https://github.com/Microsoft/visualfsharp/blob/master/License.txt</PackageLicenceUrl> | ||
<PackageProjectUrl Condition="'$(PackageProjectUrl)' == ''">https://github.com/Microsoft/visualfsharp</PackageProjectUrl> | ||
<PackageVersion Condition="'$(PackageVersion)' == ''" >$(NuGetPerBuildPreReleaseVersion)</PackageVersion> | ||
<PackageAuthors Condition="'$(PackageAuthors)' == ''" >Microsoft</PackageAuthors> | ||
<PackageTags Condition="'$(PackageTags)' == ''" >Visual F# Compiler FSharp coreclr functional programming</PackageTags> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<_CurrentPackageName>%(NugetPackageDef.Identity)</_CurrentPackageName> | ||
</PropertyGroup> | ||
|
||
<!-- Prepare args for nuget pack --> | ||
|
||
<ItemGroup> | ||
<_NuspecProperties Include='licenseUrl="$(PackageLicenceUrl)"' /> | ||
<_NuspecProperties Include='projectUrl="$(PackageProjectUrl)"' /> | ||
<_NuspecProperties Include='version=$(PackageVersion)' /> | ||
<_NuspecProperties Include='authors="$(PackageAuthors)"' /> | ||
<_NuspecProperties Include='tags="$(PackageTags)"' /> | ||
</ItemGroup> | ||
|
||
<PropertyGroup> | ||
<!-- the nuget pack output path must be relative, absolute is ignored --> | ||
<_NupkgDirectory>.$([MSBuild]::MakeRelative( $(MSBuildProjectDirectory), "$(NupkgOutputDirectory)/" ))</_NupkgDirectory> | ||
|
||
<!-- the nuget pack command fails if there is a trailing directory separator --> | ||
<_NupkgDirectory>$(_NupkgDirectory.TrimEnd('\').TrimEnd('/'))</_NupkgDirectory> | ||
</PropertyGroup> | ||
|
||
<Exec Command="dotnet nuget pack "@(NugetPackageDef -> '%(NuspecFile)')" --base-path "$(PackagingBuildBasePath)/$(_CurrentPackageName)" --exclude-empty-directories --properties @(_NuspecProperties) --output-directory "$(_NupkgDirectory)"" | ||
Condition=" '$(_CurrentPackageName)' == '%(NugetPackageDef.Identity)' " | ||
/> | ||
</Target> | ||
|
||
<Target Name="CleanPackage" | ||
DependsOnTargets="Init;SetupNugetPackagesProperties;"> | ||
|
||
<RemoveDir Directories="$(PackagingBuildBasePath)" | ||
Condition=" '$(PackagingBuildBasePath)' != '' " /> | ||
</Target> | ||
|
||
</Project> |
Oops, something went wrong.