Skip to content

Commit

Permalink
Add support for .NET Core 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
GeertvanHorrik committed Nov 29, 2018
1 parent 0d02c7a commit 449f574
Show file tree
Hide file tree
Showing 18 changed files with 198 additions and 41 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,5 @@ TestResults
.github/
BundleArtifacts/

.vscode
.vscode
FodyWeavers.xsd
1 change: 1 addition & 0 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Parameters["SolutionName"] = "Orc.CsvTextEditor";
Parameters["Company"] = "WildGums";
Parameters["RepositoryUrl"] = string.Format("https://github.com/{0}/{1}", GetBuildServerVariable("Company"), GetBuildServerVariable("SolutionName"));
Parameters["StartYear"] = "2014";
Parameters["UseVisualStudioPrerelease"] = "true";

// Note: the rest of the variables should be coming from the build server,
// see `/deployment/cake/*-variables.cake` for customization options
Expand Down
8 changes: 7 additions & 1 deletion deployment/cake/apps-uwp-tasks.cake
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,18 @@ private void BuildUwpApps()

var msBuildSettings = new MSBuildSettings {
Verbosity = Verbosity.Quiet, // Verbosity.Diagnostic
ToolVersion = MSBuildToolVersion.VS2017,
ToolVersion = MSBuildToolVersion.Default,
Configuration = ConfigurationName,
MSBuildPlatform = MSBuildPlatform.x86, // Always require x86, see platform for actual target platform
PlatformTarget = platform.Value
};

var toolPath = GetVisualStudioPath(msBuildSettings.ToolVersion);
if (!string.IsNullOrWhiteSpace(toolPath))
{
msBuildSettings.ToolPath = toolPath;
}

// See https://docs.microsoft.com/en-us/windows/uwp/packaging/auto-build-package-uwp-apps for all the details
//msBuildSettings.Properties["UseDotNetNativeToolchain"] = new List<string>(new [] { "false" });
//msBuildSettings.Properties["UapAppxPackageBuildMode"] = new List<string>(new [] { "StoreUpload" });
Expand Down
8 changes: 7 additions & 1 deletion deployment/cake/apps-web-tasks.cake
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,18 @@ private void BuildWebApps()

var msBuildSettings = new MSBuildSettings {
Verbosity = Verbosity.Quiet, // Verbosity.Diagnostic
ToolVersion = MSBuildToolVersion.VS2017,
ToolVersion = MSBuildToolVersion.Default,
Configuration = ConfigurationName,
MSBuildPlatform = MSBuildPlatform.x86, // Always require x86, see platform for actual target platform
PlatformTarget = PlatformTarget.MSIL
};

var toolPath = GetVisualStudioPath(msBuildSettings.ToolVersion);
if (!string.IsNullOrWhiteSpace(toolPath))
{
msBuildSettings.ToolPath = toolPath;
}

// Note: we need to set OverridableOutputPath because we need to be able to respect
// AppendTargetFrameworkToOutputPath which isn't possible for global properties (which
// are properties passed in using the command line)
Expand Down
8 changes: 7 additions & 1 deletion deployment/cake/apps-wpf-tasks.cake
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,18 @@ private void BuildWpfApps()

var msBuildSettings = new MSBuildSettings {
Verbosity = Verbosity.Quiet, // Verbosity.Diagnostic
ToolVersion = MSBuildToolVersion.VS2017,
ToolVersion = MSBuildToolVersion.Default,
Configuration = ConfigurationName,
MSBuildPlatform = MSBuildPlatform.x86, // Always require x86, see platform for actual target platform
PlatformTarget = PlatformTarget.MSIL
};

var toolPath = GetVisualStudioPath(msBuildSettings.ToolVersion);
if (!string.IsNullOrWhiteSpace(toolPath))
{
msBuildSettings.ToolPath = toolPath;
}

// Note: we need to set OverridableOutputPath because we need to be able to respect
// AppendTargetFrameworkToOutputPath which isn't possible for global properties (which
// are properties passed in using the command line)
Expand Down
59 changes: 55 additions & 4 deletions deployment/cake/components-tasks.cake
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,18 @@ private void BuildComponents()

var msBuildSettings = new MSBuildSettings {
Verbosity = Verbosity.Quiet, // Verbosity.Diagnostic
ToolVersion = MSBuildToolVersion.VS2017,
ToolVersion = MSBuildToolVersion.Default,
Configuration = ConfigurationName,
MSBuildPlatform = MSBuildPlatform.x86, // Always require x86, see platform for actual target platform
PlatformTarget = PlatformTarget.MSIL
};

var toolPath = GetVisualStudioPath(msBuildSettings.ToolVersion);
if (!string.IsNullOrWhiteSpace(toolPath))
{
msBuildSettings.ToolPath = toolPath;
}

// Note: we need to set OverridableOutputPath because we need to be able to respect
// AppendTargetFrameworkToOutputPath which isn't possible for global properties (which
// are properties passed in using the command line)
Expand Down Expand Up @@ -160,7 +166,8 @@ private void PackageComponents()
{
LogSeparator("Packaging component '{0}'", component);

var projectFileName = string.Format("./src/{0}/{0}.csproj", component);
var projectDirectory = string.Format("./src/{0}", component);
var projectFileName = string.Format("{0}/{1}.csproj", projectDirectory, component);

// Note: we have a bug where UAP10.0 cannot be packaged, for details see
// https://github.com/dotnet/cli/issues/9303
Expand All @@ -179,9 +186,36 @@ private void PackageComponents()

if (useDotNetPack)
{
// Step 1: remove intermediate files to ensure we have the same results on the build server, somehow NuGet
// targets tries to find the resource assemblies in [ProjectName]\obj\Release\net46\de\[ProjectName].resources.dll',
// we won't run a clean on the project since it will clean out the actual output (which we still need for packaging)

Information("Cleaning intermediate files for component '{0}'", component);

var binFolderPattern = string.Format("{0}/bin/{1}/**.dll", projectDirectory, ConfigurationName);

Information("Deleting 'bin' directory contents using '{0}'", binFolderPattern);

var binFiles = GetFiles(binFolderPattern);
DeleteFiles(binFiles);

var objFolderPattern = string.Format("{0}/obj/{1}/**.dll", projectDirectory, ConfigurationName);

Information("Deleting 'bin' directory contents using '{0}'", objFolderPattern);

var objFiles = GetFiles(objFolderPattern);
DeleteFiles(objFiles);

Information(string.Empty);

// Step 2: Go packaging!

Information("Using 'dotnet pack' to package '{0}'", component);

var msBuildSettings = new DotNetCoreMSBuildSettings();
var msBuildSettings = new DotNetCoreMSBuildSettings
{
//Verbosity = DotNetCoreVerbosity.Diagnostic // DotNetCoreVerbosity.Minimal,
};

// Note: we need to set OverridableOutputPath because we need to be able to respect
// AppendTargetFrameworkToOutputPath which isn't possible for global properties (which
Expand All @@ -191,12 +225,23 @@ private void PackageComponents()
msBuildSettings.WithProperty("ConfigurationName", ConfigurationName);
msBuildSettings.WithProperty("PackageVersion", VersionNuGet);

// Fix for .NET Core 3.0, see https://github.com/dotnet/core-sdk/issues/192, it
// uses obj/release instead of [outputdirectory]
msBuildSettings.WithProperty("DotNetPackIntermediateOutputPath", outputDirectory);

// msBuildSettings.AddFileLogger(new MSBuildFileLoggerSettings
// {
// Verbosity = DotNetCoreVerbosity.Diagnostic,
// LogFile = System.IO.Path.Combine(OutputRootDirectory, string.Format(@"MsBuild_dotnet_pack_{0}.log", component))
// });

var packSettings = new DotNetCorePackSettings
{
MSBuildSettings = msBuildSettings,
OutputDirectory = OutputRootDirectory,
Configuration = ConfigurationName,
NoBuild = true,
Verbosity = msBuildSettings.Verbosity
};

DotNetCorePack(projectFileName, packSettings);
Expand All @@ -208,12 +253,18 @@ private void PackageComponents()
var msBuildSettings = new MSBuildSettings
{
Verbosity = Verbosity.Minimal, // Verbosity.Diagnostic
ToolVersion = MSBuildToolVersion.VS2017,
ToolVersion = MSBuildToolVersion.Default,
Configuration = ConfigurationName,
MSBuildPlatform = MSBuildPlatform.x86, // Always require x86, see platform for actual target platform
PlatformTarget = PlatformTarget.MSIL
};

var toolPath = GetVisualStudioPath(msBuildSettings.ToolVersion);
if (!string.IsNullOrWhiteSpace(toolPath))
{
msBuildSettings.ToolPath = toolPath;
}

// Note: we need to set OverridableOutputPath because we need to be able to respect
// AppendTargetFrameworkToOutputPath which isn't possible for global properties (which
// are properties passed in using the command line)
Expand Down
8 changes: 7 additions & 1 deletion deployment/cake/docker-tasks.cake
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,18 @@ private void BuildDockerImages()

var msBuildSettings = new MSBuildSettings {
Verbosity = Verbosity.Quiet, // Verbosity.Diagnostic
ToolVersion = MSBuildToolVersion.VS2017,
ToolVersion = MSBuildToolVersion.Default,
Configuration = ConfigurationName,
MSBuildPlatform = MSBuildPlatform.x86, // Always require x86, see platform for actual target platform
PlatformTarget = PlatformTarget.MSIL
};

var toolPath = GetVisualStudioPath(msBuildSettings.ToolVersion);
if (!string.IsNullOrWhiteSpace(toolPath))
{
msBuildSettings.ToolPath = toolPath;
}

// Note: we need to set OverridableOutputPath because we need to be able to respect
// AppendTargetFrameworkToOutputPath which isn't possible for global properties (which
// are properties passed in using the command line)
Expand Down
23 changes: 17 additions & 6 deletions deployment/cake/generic-tasks.cake
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,23 @@ Task("Clean")
{
Information("Cleaning output for platform '{0}'", platform.Value);

MSBuild(SolutionFileName, configurator =>
configurator.SetConfiguration(ConfigurationName)
.SetVerbosity(Verbosity.Minimal)
.SetMSBuildPlatform(MSBuildPlatform.x86)
.SetPlatformTarget(platform.Value)
.WithTarget("Clean"));
var msBuildSettings = new MSBuildSettings {
Verbosity = Verbosity.Minimal,
ToolVersion = MSBuildToolVersion.Default,
Configuration = ConfigurationName,
MSBuildPlatform = MSBuildPlatform.x86, // Always require x86, see platform for actual target platform
PlatformTarget = platform.Value
};

var toolPath = GetVisualStudioPath(msBuildSettings.ToolVersion);
if (!string.IsNullOrWhiteSpace(toolPath))
{
msBuildSettings.ToolPath = toolPath;
}

msBuildSettings.Targets.Add("Clean");

MSBuild(SolutionFileName, msBuildSettings);
}
catch (System.Exception ex)
{
Expand Down
3 changes: 3 additions & 0 deletions deployment/cake/generic-variables.cake
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ var SonarUsername = GetBuildServerVariable("SonarUsername");
var SonarPassword = GetBuildServerVariable("SonarPassword");
var SonarProject = GetBuildServerVariable("SonarProject", SolutionName);

// Visual Studio
var UseVisualStudioPrerelease = bool.Parse(GetBuildServerVariable("UseVisualStudioPrerelease", "False"));

// Testing
var TestProcessBit = GetBuildServerVariable("TestProcessBit", "X86");

Expand Down
31 changes: 31 additions & 0 deletions deployment/cake/lib-generic.cake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,37 @@ private void LogSeparator()

//-------------------------------------------------------------

private string GetVisualStudioPath(MSBuildToolVersion toolVersion)
{
if (UseVisualStudioPrerelease)
{
Debug("Checking for installation of Visual Studio preview");

var path = @"C:\Program Files (x86)\Microsoft Visual Studio\Preview\Professional\MSBuild\15.0\Bin\msbuild.exe";

if (System.IO.File.Exists(path))
{
Information("Using Visual Studio preview");

return path;
}
}

// For now don't use overrides
return null;
// switch (toolVersion)
// {
// case MSBuildToolVersion.Default:
// // Latest, so don't override
// return null;

// default:
// throw new ArgumentOutOfRangeException(nameof(toolVersion), toolVersion);
// }
}

//-------------------------------------------------------------

private string GetProjectDirectory(string projectName)
{
var projectDirectory = string.Format("./src/{0}/", projectName);
Expand Down
15 changes: 14 additions & 1 deletion deployment/cake/tasks.cake
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ ValidateDockerImagesInput();

private void BuildTestProjects()
{
// In case of a local build and we have included / excluded anything, skip tests
if (IsLocalBuild && (Include.Length > 0 || Exclude.Length > 0))
{
Information("Skipping test project because this is a local build with specific includes / excludes");
return;
}

foreach (var testProject in TestProjects)
{
LogSeparator("Building test project '{0}'", testProject);
Expand All @@ -43,12 +50,18 @@ private void BuildTestProjects()
var msBuildSettings = new MSBuildSettings
{
Verbosity = Verbosity.Quiet, // Verbosity.Diagnostic
ToolVersion = MSBuildToolVersion.VS2017,
ToolVersion = MSBuildToolVersion.Default,
Configuration = ConfigurationName,
MSBuildPlatform = MSBuildPlatform.x86, // Always require x86, see platform for actual target platform
PlatformTarget = PlatformTarget.MSIL
};

var toolPath = GetVisualStudioPath(msBuildSettings.ToolVersion);
if (!string.IsNullOrWhiteSpace(toolPath))
{
msBuildSettings.ToolPath = toolPath;
}

// Force disable SonarQube
msBuildSettings.WithProperty("SonarQubeExclude", "true");

Expand Down
19 changes: 19 additions & 0 deletions src/Directory.build.shared.explicit.props
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
</PropertyGroup>

<!--
Fix for .NET Core 3.0, see https://github.com/dotnet/core-sdk/issues/192, it
uses obj/release instead of [outputdirectory]
-->
<PropertyGroup Condition=" '$(DotNetPackIntermediateOutputPath)' != '' ">
<IntermediateOutputPath>$(DotNetPackIntermediateOutputPath)</IntermediateOutputPath>
</PropertyGroup>

<ItemGroup>
<None Update="**\*.tt">
<Generator>TextTemplatingFileGenerator</Generator>
Expand Down Expand Up @@ -63,6 +71,17 @@
<DefineConstants>$(DefineConstants);NETCORE;NETCORE2_1;NETCOREAPP;NETCOREAPP2_1</DefineConstants>
</PropertyGroup>

<!-- .NET Core app 3.0 -->
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.0' ">
<DefineConstants>$(DefineConstants);NETCORE;NETCORE3_0;NETCOREAPP;NETCOREAPP3_0</DefineConstants>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.0' ">
<Compile Include="Platforms\net\**\*.cs" />
<Page Include="Platforms\net\**\*.xaml" SubType="Designer" Generator="MSBuild:Compile" />
<Compile Update="Platforms\net\**\*.xaml.cs" SubType="Code" DependentUpon="%(Filename)" />
</ItemGroup>

<!-- .NET Standard 2.0 -->
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<DefineConstants>$(DefineConstants);NETSTANDARD;NETSTANDARD2_0;NS;NS20</DefineConstants>
Expand Down
2 changes: 1 addition & 1 deletion src/Orc.CsvTextEditor.Example.NET/FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Weavers VerifyAssembly="true">
<Weavers VerifyAssembly="true" VerifyIgnoreCodes="0x80131869">
<Catel/>
<ModuleInit/>
<LoadAssembliesOnStartup/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="MSBuild.Sdk.Extras">
<PropertyGroup>
<TargetFrameworks>net462</TargetFrameworks>
<TargetFrameworks>netcoreapp3.0</TargetFrameworks>
<AssemblyName>Orc.CsvTextEditor.Example.NET</AssemblyName>
<RootNamespace>Orc.CsvTextEditor.Example</RootNamespace>
<DefaultLanguage>en-US</DefaultLanguage>
<SonarQubeExclude>true</SonarQubeExclude>
</PropertyGroup>

<PropertyGroup>
<UseWpf>true</UseWpf>
<OutputType>WinExe</OutputType>
<StartupObject />
<NoWarn>$(NoWarn);SA1652</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MSBuild.Sdk.Extras" Version="1.5.4" PrivateAssets="All" />
<PackageReference Include="Catel.Core" Version="5.6.0" />
<PackageReference Include="Catel.MVVM" Version="5.6.0" />
<PackageReference Include="Catel.Core" Version="5.9.0-alpha0015" />
<PackageReference Include="Catel.MVVM" Version="5.9.0-alpha0015" />
<PackageReference Include="Catel.Fody" Version="3.3.0" PrivateAssets="all" />
<PackageReference Include="Fody" Version="3.1.3" PrivateAssets="all">
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand Down Expand Up @@ -54,6 +54,5 @@
</EmbeddedResource>
</ItemGroup>

<Import Project="$(MSBuildSDKExtrasTargets)" Condition="Exists('$(MSBuildSDKExtrasTargets)')" />
<Import Project="$(MSBuildProjectDirectory)\..\Directory.build.shared.explicit.props" Condition="Exists('$(MSBuildProjectDirectory)\..\Directory.build.shared.explicit.props')" />
</Project>
Loading

0 comments on commit 449f574

Please sign in to comment.