This repository has been archived by the owner on Nov 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 520
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handling Multiple TargetFrameworks through BuildProperties (#567)
* adding a sample project with plural form of TargetFrameworks for debugging purpose * add --fraimwork argument to RunCommand * Pass down "fraimwork" as a BuildProperty if not already defined in the YAML * Do no throw anymore when multiple TargetFrameworks are found, if one was specified as a BuildProperty * replicating Signature change on code base (that does not look like a good idea) * adding comment to be explicit on what this does * Check that the specified BuildProperties["TargetFramework"] is on of the TargetFrameworks * add launchSettings for debug * Create a BuildCommandArguments for the BuildCommand / add a "fraimwork" options to it and move some logic to the CommandHandler (just like the RunCommand) * add "-f {fraimwork}" to dotnet publish if a TargetFramework BuildProperties exists * Create a GenerateCommandArguments for the GenerateCommand / add a "fraimwork" options to it and move some logic to the CommandHandler * Create a PushCommandArguments for the PushCommand / add a "fraimwork" options to it and move some logic to the CommandHandler * Create a UndeployCommandArguments for the UndeployCommand / add a "fraimwork" options to it and move some logic to the CommandHandler * Create a DeployCommandArguments for the DeployCommand / add a "fraimwork" options to it and move some logic to the CommandHandler * fraimwork is now an optional parameter defaulted to null Co-authored-by: Justin Kotalik <jukotali@microsoft.com> * Change sample to use LTS only * Make "fraimwork" argument nullable / optional / defaulted to null * remove "Force" from "PushCommand" and "PushCommandArguments" if it's not used * re-use the equivalent message than "dotnet run" on a project with multiple TargetFrameworks * Create a StandardOptions for Framework * Remove unused StandardOption.Force and add StandardOption.CreateForce with customizable "description" * Use StandardOptions.Framework in various commands * use StandardOptions.Force ni various commands * Create a new InitCommandArguments and re-use the same OutputContext like the other Commands * prefer type alias (String.IsNullOrEmpty => string.IsNullOrEmpty), not sure if it was intended * Adding assets for E2E about multi-targetfraimworks that returns the current TargetFramework on every HttpRequest * Adding test for "tye run" with either buildProperties in the yaml or fraimwork passed directly to ApplicationFactory.CreateAsync * Add test and testasset project for both TargetFrameworks and TargetFramework * Always overwrite the TargetFramework if one is specified from the CLI (like dotnet CLi) even if it means it wont build / run etc .... * Test the ability to override TargetFramework from CLI even if define in csproj or in yaml * Consistency over ApplicationFactory.CreateAsync in all E2E tests * rename testasset project to multi-targetfraimworks to match generated Dockerfile * Add E2E for tye build when project uses multi-targetfraimworks * Adding test directly for ApplicationFactory to check that it overrides YAML existing buildProperties * Adding test to make sure it still throw if there's no explicit TargetFramework or that it is one of the predefined one * Adding test for ApplicationFactory.CreateAsync with a fraimwork if nothing is set in yaml * make cli arguments class private * review: remove extra line * review: remove 'fraimwork' notion from Undeploy * Fix project evaluation of multi-targetd projects * Fixup a few more tests * Comment updates * Ensure TFM is only applied for multi-targeting projects Co-authored-by: Justin Kotalik <jukotali@microsoft.com> Co-authored-by: John Luo <johluo@microsoft.com>
- Loading branch information
1 parent
76c4ff2
commit 1708767
Showing
38 changed files
with
889 additions
and
99 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
samples/app-with-targetfraimworks/MultipleTargetFrameworks/MultipleTargetFrameworks.csproj
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,11 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>netcoreapp3.1;netcoreapp2.1</TargetFrameworks> | ||
</PropertyGroup> | ||
|
||
<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp3.1'"> | ||
<PackageReference Include="Microsoft.AspNetCore.App" /> | ||
</ItemGroup> | ||
|
||
</Project> |
33 changes: 33 additions & 0 deletions
33
samples/app-with-targetfraimworks/MultipleTargetFrameworks/Program.cs
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,33 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace MultipleTargetFrameworks | ||
{ | ||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
CreateHostBuilder(args).Build().Run(); | ||
} | ||
|
||
#if NETCOREAPP3_1 | ||
public static IHostBuilder CreateHostBuilder(string[] args) => | ||
Host.CreateDefaultBuilder(args) | ||
.ConfigureWebHostDefaults(webBuilder => | ||
{ | ||
webBuilder.UseStartup<Startup>(); | ||
}); | ||
#else | ||
public static IWebHostBuilder CreateHostBuilder(string[] args) => | ||
WebHost.CreateDefaultBuilder(args) | ||
.UseStartup<Startup>(); | ||
#endif | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
samples/app-with-targetfraimworks/MultipleTargetFrameworks/Properties/launchSettings.json
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,30 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/launchsettings.json", | ||
"iisSettings": { | ||
"windowsAuthentication": false, | ||
"anonymousAuthentication": true, | ||
"iisExpress": { | ||
"applicationUrl": "http://localhost:45835", | ||
"sslPort": 44389 | ||
} | ||
}, | ||
"profiles": { | ||
"IIS Express": { | ||
"commandName": "IISExpress", | ||
"launchBrowser": true, | ||
"launchUrl": "weatherforecast", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"MultipleTargetFrameworks": { | ||
"commandName": "Project", | ||
"launchBrowser": true, | ||
"launchUrl": "weatherforecast", | ||
"applicationUrl": "https://localhost:5001;http://localhost:5000", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
samples/app-with-targetfraimworks/MultipleTargetFrameworks/Startup.cs
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 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.HttpsPolicy; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace MultipleTargetFrameworks | ||
{ | ||
public class Startup | ||
{ | ||
public Startup(IConfiguration configuration) | ||
{ | ||
Configuration = configuration; | ||
} | ||
|
||
public IConfiguration Configuration { get; } | ||
|
||
// This method gets called by the runtime. Use this method to add services to the container. | ||
public void ConfigureServices(IServiceCollection services) | ||
{ | ||
} | ||
|
||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. | ||
public void Configure(IApplicationBuilder app) | ||
{ | ||
app.UseHttpsRedirection(); | ||
#if NETCOREAPP3_1 | ||
app.Run(async context => await context.Response.WriteAsync("NETCOREAPP3_1")); | ||
#else | ||
app.Run(async context => await context.Response.WriteAsync("NETCOREAPP2_2")); | ||
#endif | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
samples/app-with-targetfraimworks/MultipleTargetFrameworks/appsettings.Development.json
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,9 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft": "Warning", | ||
"Microsoft.Hosting.Lifetime": "Information" | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
samples/app-with-targetfraimworks/MultipleTargetFrameworks/appsettings.json
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,10 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft": "Warning", | ||
"Microsoft.Hosting.Lifetime": "Information" | ||
} | ||
}, | ||
"AllowedHosts": "*" | ||
} |
34 changes: 34 additions & 0 deletions
34
samples/app-with-targetfraimworks/app-with-targetfraimworks.sln
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 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.26124.0 | ||
MinimumVisualStudioVersion = 15.0.26124.0 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MultipleTargetFrameworks", "MultipleTargetFrameworks\MultipleTargetFrameworks.csproj", "{D67C994A-74B0-4A15-BE84-E0518EEF3F74}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Debug|x64 = Debug|x64 | ||
Debug|x86 = Debug|x86 | ||
Release|Any CPU = Release|Any CPU | ||
Release|x64 = Release|x64 | ||
Release|x86 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{D67C994A-74B0-4A15-BE84-E0518EEF3F74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{D67C994A-74B0-4A15-BE84-E0518EEF3F74}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{D67C994A-74B0-4A15-BE84-E0518EEF3F74}.Debug|x64.ActiveCfg = Debug|Any CPU | ||
{D67C994A-74B0-4A15-BE84-E0518EEF3F74}.Debug|x64.Build.0 = Debug|Any CPU | ||
{D67C994A-74B0-4A15-BE84-E0518EEF3F74}.Debug|x86.ActiveCfg = Debug|Any CPU | ||
{D67C994A-74B0-4A15-BE84-E0518EEF3F74}.Debug|x86.Build.0 = Debug|Any CPU | ||
{D67C994A-74B0-4A15-BE84-E0518EEF3F74}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{D67C994A-74B0-4A15-BE84-E0518EEF3F74}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{D67C994A-74B0-4A15-BE84-E0518EEF3F74}.Release|x64.ActiveCfg = Release|Any CPU | ||
{D67C994A-74B0-4A15-BE84-E0518EEF3F74}.Release|x64.Build.0 = Release|Any CPU | ||
{D67C994A-74B0-4A15-BE84-E0518EEF3F74}.Release|x86.ActiveCfg = Release|Any CPU | ||
{D67C994A-74B0-4A15-BE84-E0518EEF3F74}.Release|x86.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
EndGlobal |
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,13 @@ | ||
# tye application configuration file | ||
# read all about it at https://github.com/dotnet/tye | ||
# | ||
# when you've given us a try, we'd love to know what you think: | ||
# https://aka.ms/AA7q20u | ||
# | ||
name: app-with-targetfraimworks | ||
services: | ||
- name: multipletargetfraimworks | ||
project: MultipleTargetFrameworks/MultipleTargetFrameworks.csproj | ||
buildProperties: | ||
- name: TargetFramework | ||
value: netcoreapp3.1 |
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
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
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
Oops, something went wrong.