Skip to content

Commit

Permalink
[build] Configure for publishing in trimmed mode; Add/fix publishing …
Browse files Browse the repository at this point in the history
…profiles for testing, update publish.ps1 script; Exclude Sonar stuff;

Fixes v0.7.0.0 release missing .Net 5 dependency at runtime.
  • Loading branch information
mpaperno committed Apr 18, 2022
1 parent 1cf22dc commit e90f50d
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>MSFSTouchPortalPlugin_Generator</RootNamespace>
<CodeAnalysisRuleSet>..\.sonarlint\msfstouchportalplugincsharp.ruleset</CodeAnalysisRuleSet>
<Platforms>x64</Platforms>
<Version>1.2.0</Version>
<OutputPath>..\build\$(Platform)-$(Configuration)\</OutputPath>
<Configurations>Debug;Release;Publish</Configurations>
<!--<CodeAnalysisRuleSet>..\.sonarlint\msfstouchportalplugincsharp.ruleset</CodeAnalysisRuleSet>-->
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
Expand All @@ -16,7 +17,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<PropertyGroup Condition="('$(Configuration)'=='Release' Or '$(Configuration)'=='Publish') And '$(Platform)'=='x64'">
<PlatformTarget>x64</PlatformTarget>
<NoWarn>1701;1702</NoWarn>
<DefineConstants />
Expand All @@ -28,9 +29,11 @@
</AllowedReferenceRelatedFileExtensions>
</PropertyGroup>

<!--
<ItemGroup>
<AdditionalFiles Include="..\.sonarlint\msfstouchportalplugin\CSharp\SonarLint.xml" Link="SonarLint.xml" />
</ItemGroup>
-->

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.8.0" />
Expand All @@ -42,4 +45,28 @@
<ProjectReference Include="..\MSFSTouchPortalPlugin\MSFSTouchPortalPlugin.csproj" />
</ItemGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Publish|x64'">
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishTrimmed>True</PublishTrimmed>
<TrimMode>copyused</TrimMode>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun>False</PublishReadyToRun>
</PropertyGroup>

<!-- required for trimming otherwise we get missing dependencies at runtime -->
<ItemGroup>
<TrimmerRootAssembly Include="mscorlib" />
<TrimmerRootAssembly Include="netstandard" />
</ItemGroup>

<!-- somehow this is required for trimming to work properly, otherwise we get an exception during build -->
<ItemGroup Condition="'$(Configuration)'=='Publish'">
<Reference Include="Microsoft.FlightSimulator.SimConnect">
<HintPath>..\MSFSTouchPortalPlugin\lib\Microsoft.FlightSimulator.SimConnect.dll</HintPath>
<EmbedInteropTypes>false</EmbedInteropTypes>
<Private>true</Private>
</Reference>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Configuration>Release</Configuration>
<Configuration>Publish</Configuration>
<Platform>x64</Platform>
<TargetFramework>netcoreapp3.1</TargetFramework>
<PublishDir>..\dist\win-x64</PublishDir>
<PublishDir>..\dist</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>net5.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun>False</PublishReadyToRun>
<PublishTrimmed>False</PublishTrimmed>
<PublishTrimmed>True</PublishTrimmed>
</PropertyGroup>
</Project>
14 changes: 12 additions & 2 deletions MSFSTouchPortalPlugin.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitignore = .gitignore
actions = actions
airplane_takeoff1600.png = airplane_takeoff1600.png
airplane_takeoff24.png = airplane_takeoff24.png
build.ps1 = build.ps1
Expand All @@ -23,11 +22,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
publish.ps1 = publish.ps1
README.md = README.md
sonarcube.ps1 = sonarcube.ps1
states = states
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{BB11FB83-1407-4C82-AA08-67D7BB5A106B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{7FEA40CD-379E-48F1-9581-2692B532A839}"
ProjectSection(SolutionItems) = preProject
.github\workflows\verify-build.yml = .github\workflows\verify-build.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ISSUE_TEMPLATE", "ISSUE_TEMPLATE", "{D74D033D-8E79-4CCD-9D07-7CD7CD2FEF49}"
ProjectSection(SolutionItems) = preProject
.github\ISSUE_TEMPLATE\bug-report.md = .github\ISSUE_TEMPLATE\bug-report.md
Expand All @@ -46,19 +49,25 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Publish|x64 = Publish|x64
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D3F1B2FB-0846-4003-8D2E-355273668F37}.Debug|x64.ActiveCfg = Debug|x64
{D3F1B2FB-0846-4003-8D2E-355273668F37}.Debug|x64.Build.0 = Debug|x64
{D3F1B2FB-0846-4003-8D2E-355273668F37}.Publish|x64.ActiveCfg = Publish|x64
{D3F1B2FB-0846-4003-8D2E-355273668F37}.Publish|x64.Build.0 = Publish|x64
{D3F1B2FB-0846-4003-8D2E-355273668F37}.Release|x64.ActiveCfg = Release|x64
{D3F1B2FB-0846-4003-8D2E-355273668F37}.Release|x64.Build.0 = Release|x64
{53A38611-6486-4FF5-8637-1C6BC38A6A18}.Debug|x64.ActiveCfg = Debug|x64
{53A38611-6486-4FF5-8637-1C6BC38A6A18}.Debug|x64.Build.0 = Debug|x64
{53A38611-6486-4FF5-8637-1C6BC38A6A18}.Publish|x64.ActiveCfg = Publish|x64
{53A38611-6486-4FF5-8637-1C6BC38A6A18}.Publish|x64.Build.0 = Publish|x64
{53A38611-6486-4FF5-8637-1C6BC38A6A18}.Release|x64.ActiveCfg = Release|x64
{53A38611-6486-4FF5-8637-1C6BC38A6A18}.Release|x64.Build.0 = Release|x64
{562A58FF-DD9A-4839-B503-4520D3BE96DA}.Debug|x64.ActiveCfg = Debug|x64
{562A58FF-DD9A-4839-B503-4520D3BE96DA}.Debug|x64.Build.0 = Debug|x64
{562A58FF-DD9A-4839-B503-4520D3BE96DA}.Publish|x64.ActiveCfg = Release|x64
{562A58FF-DD9A-4839-B503-4520D3BE96DA}.Release|x64.ActiveCfg = Release|x64
{562A58FF-DD9A-4839-B503-4520D3BE96DA}.Release|x64.Build.0 = Release|x64
EndGlobalSection
Expand All @@ -67,6 +76,7 @@ Global
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{BB11FB83-1407-4C82-AA08-67D7BB5A106B} = {6DF0C85E-3EB4-4898-A304-EFA04CB547A6}
{7FEA40CD-379E-48F1-9581-2692B532A839} = {BB11FB83-1407-4C82-AA08-67D7BB5A106B}
{D74D033D-8E79-4CCD-9D07-7CD7CD2FEF49} = {BB11FB83-1407-4C82-AA08-67D7BB5A106B}
{8781784E-631E-4D29-A3A1-9CBEFBC01310} = {BB11FB83-1407-4C82-AA08-67D7BB5A106B}
EndGlobalSection
Expand Down
35 changes: 27 additions & 8 deletions MSFSTouchPortalPlugin/MSFSTouchPortalPlugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>MSFSTouchPortalPlugin</RootNamespace>
<Version>0.7.0.0-mp</Version>
<CodeAnalysisRuleSet>..\.sonarlint\msfstouchportalplugincsharp.ruleset</CodeAnalysisRuleSet>
<Version>0.7.0.1-mp</Version>
<Platforms>x64</Platforms>
<OutputPath>..\build\$(Platform)-$(Configuration)\</OutputPath>
<OutputPath>..\build\$(Platform)-$(Configuration)\</OutputPath>
<AnalysisLevel>5.0</AnalysisLevel>
<Configurations>Debug;Release;Publish</Configurations>
<!--<CodeAnalysisRuleSet>..\.sonarlint\msfstouchportalplugincsharp.ruleset</CodeAnalysisRuleSet>-->
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<PlatformTarget>x64</PlatformTarget>
<DefineConstants>DEBUG;TRACE;DEBUG_REQUESTS</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<PropertyGroup Condition="('$(Configuration)'=='Release' Or '$(Configuration)'=='Publish') And '$(Platform)'=='x64'">
<PlatformTarget>x64</PlatformTarget>
<NoWarn>1701;1702</NoWarn>
<AllowedReferenceRelatedFileExtensions>
Expand All @@ -27,11 +29,26 @@
<DefineConstants />
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Publish|x64'">
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishTrimmed>True</PublishTrimmed>
<TrimMode>copyused</TrimMode>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun>False</PublishReadyToRun>
</PropertyGroup>

<!-- required for trimming otherwise we get missing dependencies at runtime -->
<ItemGroup>
<TrimmerRootAssembly Include="mscorlib" />
<TrimmerRootAssembly Include="netstandard" />
</ItemGroup>

<ItemGroup>
<AdditionalFiles Include="..\.sonarlint\msfstouchportalplugin\CSharp\SonarLint.xml" Link="SonarLint.xml" />
<Content Include="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<!--<AdditionalFiles Include="..\.sonarlint\msfstouchportalplugin\CSharp\SonarLint.xml" Link="SonarLint.xml" />-->
</ItemGroup>

<ItemGroup>
Expand All @@ -44,13 +61,15 @@
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" />
<PackageReference Include="System.Runtime.Handles" Version="4.3.0" />
<PackageReference Include="System.Text.Encoding.Extensions" Version="4.3.0" />
<!--
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.34.0.42011">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" />
<PackageReference Include="System.Runtime.Handles" Version="4.3.0" />
<PackageReference Include="System.Text.Encoding.Extensions" Version="4.3.0" />
-->
</ItemGroup>

<!-- SimConnect libs -->
Expand Down

This file was deleted.

18 changes: 18 additions & 0 deletions MSFSTouchPortalPlugin/Properties/PublishProfiles/win-x64.pubxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Configuration>Publish</Configuration>
<Platform>x64</Platform>
<TargetFramework>net5.0</TargetFramework>
<PublishDir>..\dist</PublishDir>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun>False</PublishReadyToRun>
<PublishTrimmed>True</PublishTrimmed>
</PropertyGroup>
</Project>
6 changes: 3 additions & 3 deletions publish.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Param(
[string]$ProjectName = "MSFSTouchPortalPlugin",
[string]$DistroName = "MSFS-TouchPortal-Plugin",
[string]$Configuration = "Release",
[string]$Configuration = "Publish",
[string]$Platform = "x64",
[String]$VersionSuffix = "",
[switch]$Clean = $false,
Expand All @@ -26,10 +26,10 @@ if (Test-Path $PluginFilesPath) {
}

Write-Information "`nPublishing '$ProjectName' component to '$BinFilesPath' ...`n" -InformationAction Continue
dotnet publish "$ProjectName" --output "$BinFilesPath" --configuration $Configuration -p:Platform=$Platform $VersionSuffixCommand $VersionSuffix -r "win-$Platform"
dotnet publish "$ProjectName" --output "$BinFilesPath" --configuration $Configuration -p:Platform=$Platform $VersionSuffixCommand $VersionSuffix

Write-Information "`nPublishing '$ProjectName-Generator' component...`n" -InformationAction Continue
dotnet publish "$ProjectName-Generator" --output "$BinFilesPath" --configuration $Configuration -p:Platform=$Platform -r "win-$Platform" /p:ValidateExecutableReferencesMatchSelfContained=false
dotnet publish "$ProjectName-Generator" --output "$BinFilesPath" --configuration $Configuration -p:Platform=$Platform

# Run Documentation
Write-Information "`nGenerating entry.tp JSON and Documentation..." -InformationAction Continue
Expand Down

0 comments on commit e90f50d

Please sign in to comment.