Skip to content

Installer updates (Merge to SDK Changeset) #17959

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

Merged
merged 51 commits into from
Apr 6, 2024
Merged

Conversation

MiYanni
Copy link
Member

@MiYanni MiYanni commented Dec 13, 2023

Sibling branch: https://github.com/dotnet/sdk/tree/feature/installer-merge

Summary

The work in this PR is in preparation for merging this repo into the SDK repo. The changes I've made here will be the general format that the files will be when moved to the SDK repo. You can take a look a the linked sibling branch to see these files and how they'll be in the SDK repo.

Because this endeavor is taking a phased approach, it will be easier to maintain updates to these files in the SDK repo if the files in the Installer repo match a similar format/form. Therefore, I believe it makes the most sense to merge this PR into the Installer repo, even though we plan on phasing out this repo (at a later date).

High-Level Changes

  • Formatting and cleanup of most of the files in the repo
  • Usage of Microsoft.Build.NoTargets for projects that don't require building assemblies
  • Minor changes in some of the core-sdk-tasks code to use an explicit type instead of ValueTuples
  • Simplification of the finalizer build process
  • Reduction in folder nesting for src (some projects/files combined into other project folders)
  • Removed LayoutTool.csproj and used DownloadPackage.csproj with the added logic for tool acquisition in BundledDotnetTools.targets

Things of Note

  • When comparing the differences between these changes and the SDK repo's branch:
    • This repo doesn't use Directory.Packages.props, so versioning of packages is explicit within projects
    • This repo doesn't use global usings, so there are many more using statements in the source files
  • Currently, there are manual dependency version changes. This is only done for the purposes of comparing the output between the repos. These changes will be reverted prior to merge.
    • Fixed.
  • Some TODOs exist. These will be removed prior to merge.
    • Fixed.
  • There will be conflicts as syncing updates is a process I need to do between this repo and the SDK branch.

Finalizer Changes Details

The current process for building finalizer proceeds as such:

  • eng/Build.props builds eng/version.csproj and eng/native.proj
    • eng/version.csproj's only purpose is to call the GenerateSdkVersionFile target. Additionally, this project is only used in the finalizer build process.
    • eng/native.proj's only purpose is to call Native.sln and pass Platform (set using the $(Architecture) property) to the solution.
  • Native.sln only contains a single project, src/finalizer_shim/finalizer_shim.csproj
  • finalizer_shim.csproj provides the data to the CMake SDK to build the src/finalizer/finalizer.proj and runs the build of that project. Also, it copies WixSdk contents to use in the build.
  • finalizer.proj sets the CMakeLists.txt file and defines the Platform variable
  • CMakeLists.txt contains the actual build logic for creating finalizer.exe

I've simplified the build process as such:

  • eng/Build.props builds src\finalizer\finalizer-build.csproj
  • finalizer-build.csproj contains the GenerateSdkVersionFile target, provides the CMake SDK data, copies WixSdk contents, and builds finalizer.nativeproj
  • finalizer.nativeproj uses TreatAsLocalProperty="Platform" to set the property for its build, sets the CMakeLists.txt file, and defines the Platform and ArtifactsDir variables
  • CMakeLists.txt contains the actual build logic for creating finalizer.exe

Because of this, I was able to remove:

  • eng/version.csproj
  • eng/native.proj
  • Native.sln

Since the whole process only stems from one project, finalizer-build.csproj, this made it easier to work with in the SDK repo.

Test Builds

…be necessary. Manual formatting cleanup for targets in the redist project.
…he target from LayoutTool.csproj directly into where it was used in BundledDotnetTools.targets. Added comments to DownloadPackage.csproj.
…der redist. Added more comments to DownloadPackage.csproj.
@MiYanni MiYanni changed the title [WIP] Installer (Merge to SDK) - Changeset [NO MERGE] Installer (Merge to SDK) - Changeset Dec 13, 2023
…an up formatting in SdkTests.csproj. Removed the empty <TargetPath></TargetPath> from SdkTests.csproj to allow loading in VS.
…teLocator.csproj projects. Added the projects back to the SLN so they build using the proper configuration (debug/release).
…jects only ever build with the default configuration (Debug) since it is irrelevant for packaging. Updated the paths used when creating the MSIs, which uses the output of these to create NuGet packages.
…ller-merge-update

# Conflicts:
#	eng/Version.Details.xml
#	eng/Versions.props
#	global.json
#	src/redist/targets/Crossgen.targets
#	src/redist/targets/GenerateBundledVersions.targets
#	src/redist/targets/GenerateLayout.targets
#	src/redist/targets/GenerateMSIs.targets
…from SdkTests as it hasn't existed in years...?
<SdkStableFileIdForApphostTransform>$(MSBuildThisFileDirectory)packaging/windows/clisdk/stablefileidforapphosttransform.xslt</SdkStableFileIdForApphostTransform>
<SdkGenerateBundlePowershellScript>$(MSBuildThisFileDirectory)packaging/windows/clisdk/generatebundle.ps1</SdkGenerateBundlePowershellScript>
<GenerateNupkgPowershellScript>$(MSBuildThisFileDirectory)packaging/windows/clisdk/generatenupkg.ps1</GenerateNupkgPowershellScript>
<SdkPkgSourcesRootDirectory>$(MSBuildThisFileDirectory)../packaging/windows</SdkPkgSourcesRootDirectory>
Copy link
Member Author

Choose a reason for hiding this comment

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

Added this to simply all of these path properties.

Copy link
Member Author

Choose a reason for hiding this comment

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

A few of the targets files had this problem where the content in the file was indented incorrectly. It makes it look like I changed a lot, but all I did was fix the tab alignment.

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed in favor of DownloadPackage.csproj instead.

Comment on lines -58 to +60
string configuration = new DirectoryInfo(AppContext.BaseDirectory).Parent.Name;
// https://stackoverflow.com/a/60545278/294804
var assemblyConfigurationAttribute = typeof(RepoDirectoriesProvider).Assembly.GetCustomAttribute<AssemblyConfigurationAttribute>();
string configuration = assemblyConfigurationAttribute?.Configuration;
Copy link
Member Author

Choose a reason for hiding this comment

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

Simplification as the parent directory's name is not the same between the Installer repo and SDK repo. The point of this is to simply get the build configuration. So, I directly get that information from the assembly information.

Comment on lines -193 to +187
<Exec Command="$(ToolRunPrefix)$(InstallToolCommand)"
WorkingDirectory="$(TestLocalToolFolder)"
EnvironmentVariables="DOTNET_CLI_HOME=$(DOTNET_CLI_HOME)"/>

<!--<Exec Command="$(ToolRunPrefix)dotnet tool restore"
<Exec Command="$(ToolRunPrefix)$(InstallToolCommand)"
WorkingDirectory="$(TestLocalToolFolder)"
EnvironmentVariables="DOTNET_CLI_HOME=$(DOTNET_CLI_HOME)"/>-->
EnvironmentVariables="DOTNET_CLI_HOME=$(DOTNET_CLI_HOME)" />
Copy link
Member Author

Choose a reason for hiding this comment

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

The diffing here looks weird but all I did was remove commented code.

Comment on lines -257 to -260
<PropertyGroup>
<TargetPath></TargetPath>
<!-- Prevent projects referencing this from trying to pass us to the compiler -->
</PropertyGroup>
Copy link
Member Author

Choose a reason for hiding this comment

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

This makes the project inoperable in Visual Studio as the project system requires that TargetPath have a value.

Copy link
Member

Choose a reason for hiding this comment

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

Should that be conditioned on the IsBuildingInVisualStudio property or something?

Copy link
Member Author

Choose a reason for hiding this comment

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

Should that be conditioned on the IsBuildingInVisualStudio property or something?

I'll respond to your question with a question, does <TargetPath></TargetPath> have a purpose? The comment under it implies that SdkTests.csproj is referenced by other projects, but it isn't. Nothing references this project.

@@ -267,12 +250,10 @@
<!-- Group always attempts resolve runtime, regardless of <CopyNuGetImplementations>-->
<Target Name="GetReferenceAssemblyPaths" />
<!-- Don't go looking for framework reference assemblies-->
<Target Name="GetFrameworkPaths" />
<!-- ^ -->
Copy link
Member Author

Choose a reason for hiding this comment

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

^^

@@ -37,7 +37,6 @@
<Method Name="Microsoft.NET.Publish.Tests.GivenThatWeWantToPublishASelfContainedApp.It_can_make_a_Windows_GUI_exe" />
<Class Name="Microsoft.NET.Publish.Tests.GivenThatWeWantToPublishASingleFileApp" />
<Class Name="Microsoft.NET.Publish.Tests.GivenThatWeWantToPublishAWebApp" />
<Class Name="Microsoft.NET.Publish.Tests.GivenThatWeWantToRunCrossgen" />
Copy link
Member Author

Choose a reason for hiding this comment

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

This test doesn't exist anymore. I found it existing in 2019 but I didn't walk the entire file history to see when it was deleted.

Copy link
Member

Choose a reason for hiding this comment

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

This sort of thing will hopefully become easier once everything is one repo

Copy link
Member Author

@MiYanni MiYanni Apr 2, 2024

Choose a reason for hiding this comment

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

Well, this file isn't being migrated since it was for running SDK tests in this repo. I went through and confirmed these tests being in the SDK repo already, so I don't need to do anything with the entire SdkTests project. This cleanup just came out of that review.

…ssary. Updated or removed TODO comments. Fixed some tabbing from merging. Fixed a compilation bug if this code is ever built against 4.5.1(????)
…et prior to calling the Arcade SDK, so the OutputPath properly includes the Architecture folder.
@@ -6,7 +6,6 @@
using Microsoft.Build.Utilities;
using Microsoft.Build.Framework;
using System.IO;
Copy link
Member

Choose a reason for hiding this comment

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

Since you're cleaning up some of the code, might as well sort the usings too

Copy link
Member Author

Choose a reason for hiding this comment

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

So, I didn't run the same formatters/analyzers like I did in the SDK repo on this code. Here, I likely just did "Remove unused usings". However, the point is kinda moot when you look at this file in the SDK PR:
https://github.com/dotnet/sdk/pull/38804/files#diff-ea4fa261d2db3cc7e1e241b5f6ac3a003ff19fdde37c09ddb089b7467277160dR4

There's only 1 using because all of these are in the global usings of that repo. So... 🙃

@@ -183,14 +179,11 @@ private string BuildCmdParameters(ConfigJson configJson, string package_version)

// Map all the payload directories as they need to install on the system
if (configJson.Install_Root != null)
Copy link
Member

Choose a reason for hiding this comment

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

Time for me to rant. I think our general style guidelines have always been to have braces for if statements, though if you really want to you may be able to use conditionals and discard statements. Not a big issue since this code has been around for a long time I think

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh definitely. But there's code in the SDK repo that doesn't follow ANY guidelines... that was written in 2006, originally from .NET Framework. I think there are more formatting guidelines I'd like to turn on in the SDK repo, but I don't have a complete list yet. I'll mention I didn't do "complete" cleanup to the code here. It was more like spot checks and some automatic tasks in VS. I did a lot of these in December when I was trying to understand the scope and projects in this repo for migration.

<CMakeDefines Include="Platform" Value="$(Platform)" />
<CMakeDefines Include="ArtifactsDir" Value="$(ArtifactsDirForCMake)" />
<!-- Include this item below to create a binlog for the native build. -->
<!-- <CMakeNativeToolArguments Include="/bl:$(ArtifactsDirForCMake)native.binlog" /> -->
Copy link
Member

Choose a reason for hiding this comment

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

Any reason why this is commented out? Do we want it enabled by default or otherwise hide it behind a conditional property? Having binlogs for everything is useful when investigating build failures I think

Copy link
Member Author

Choose a reason for hiding this comment

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

It was there in the file already (meaning, it was commented out in the file) and I figured that you put it there for yourself. Lol. I didn't look at the blame on it, though. I haven't actually tested with it being on, but I can do that and see if we just want to keep it on always.

Copy link
Member

@nagilson nagilson left a comment

Choose a reason for hiding this comment

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

Whoops, this was supposed to be on the other PR, let me dismiss this... 😄

@nagilson nagilson self-requested a review March 13, 2024 22:34
@MiYanni MiYanni requested a review from a team as a code owner April 2, 2024 22:47
Copy link
Member

@ViktorHofer ViktorHofer left a comment

Choose a reason for hiding this comment

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

Approving the src/SourceBuild change

MiYanni added 2 commits April 5, 2024 11:17
…ller-merge-update

# Conflicts:
#	.vsts-ci.yml
#	eng/Publishing.props
#	eng/Versions.props
#	eng/build.yml
#	global.json
#	src/redist/targets/BundledTemplates.targets
#	src/redist/targets/GenerateBundledVersions.targets
#	src/redist/targets/Versions.targets
# Conflicts:
#	eng/Version.Details.xml
#	eng/Versions.props
#	global.json
@MiYanni MiYanni enabled auto-merge April 5, 2024 20:59
@MiYanni MiYanni merged commit 899cd0f into main Apr 6, 2024
@MiYanni MiYanni deleted the feature/installer-merge branch April 6, 2024 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants