mirror of https://github.com/dotnet/tye.git
Browse Source
* adding a sample project with plural form of TargetFrameworks for debugging purpose
* add --framework argument to RunCommand
* Pass down "framework" 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 "framework" options to it and move some logic to the CommandHandler (just like the RunCommand)
* add "-f {framework}" to dotnet publish if a TargetFramework BuildProperties exists
* Create a GenerateCommandArguments for the GenerateCommand / add a "framework" options to it and move some logic to the CommandHandler
* Create a PushCommandArguments for the PushCommand / add a "framework" options to it and move some logic to the CommandHandler
* Create a UndeployCommandArguments for the UndeployCommand / add a "framework" options to it and move some logic to the CommandHandler
* Create a DeployCommandArguments for the DeployCommand / add a "framework" options to it and move some logic to the CommandHandler
* framework is now an optional parameter defaulted to null
Co-authored-by: Justin Kotalik <jukotali@microsoft.com>
* Change sample to use LTS only
* Make "framework" 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-targetframeworks that returns the current TargetFramework on every HttpRequest
* Adding test for "tye run" with either buildProperties in the yaml or framework 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-targetframeworks to match generated Dockerfile
* Add E2E for tye build when project uses multi-targetframeworks
* 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 framework if nothing is set in yaml
* make cli arguments class private
* review: remove extra line
* review: remove 'framework' 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>
pull/722/head
committed by
GitHub
38 changed files with 889 additions and 99 deletions
@ -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> |
|||
@ -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
|
|||
} |
|||
} |
|||
@ -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" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -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
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
{ |
|||
"Logging": { |
|||
"LogLevel": { |
|||
"Default": "Information", |
|||
"Microsoft": "Warning", |
|||
"Microsoft.Hosting.Lifetime": "Information" |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
{ |
|||
"Logging": { |
|||
"LogLevel": { |
|||
"Default": "Information", |
|||
"Microsoft": "Warning", |
|||
"Microsoft.Hosting.Lifetime": "Information" |
|||
} |
|||
}, |
|||
"AllowedHosts": "*" |
|||
} |
|||
@ -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 |
|||
@ -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-targetframeworks |
|||
services: |
|||
- name: multipletargetframeworks |
|||
project: MultipleTargetFrameworks/MultipleTargetFrameworks.csproj |
|||
buildProperties: |
|||
- name: TargetFramework |
|||
value: netcoreapp3.1 |
|||
@ -0,0 +1,9 @@ |
|||
{ |
|||
"profiles": { |
|||
"tye": { |
|||
"commandName": "Project", |
|||
"commandLineArgs": "build --framework netcoreapp3.1", |
|||
"workingDirectory": "..\\..\\samples\\app-with-targetframeworks\\" |
|||
} |
|||
} |
|||
} |
|||
@ -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}") = "multi-targetframeworks", "multi-targetframeworks\multi-targetframeworks.csproj", "{CA427ACE-098F-4883-8A91-02F766FC2D46}" |
|||
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 |
|||
{CA427ACE-098F-4883-8A91-02F766FC2D46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|||
{CA427ACE-098F-4883-8A91-02F766FC2D46}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|||
{CA427ACE-098F-4883-8A91-02F766FC2D46}.Debug|x64.ActiveCfg = Debug|Any CPU |
|||
{CA427ACE-098F-4883-8A91-02F766FC2D46}.Debug|x64.Build.0 = Debug|Any CPU |
|||
{CA427ACE-098F-4883-8A91-02F766FC2D46}.Debug|x86.ActiveCfg = Debug|Any CPU |
|||
{CA427ACE-098F-4883-8A91-02F766FC2D46}.Debug|x86.Build.0 = Debug|Any CPU |
|||
{CA427ACE-098F-4883-8A91-02F766FC2D46}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|||
{CA427ACE-098F-4883-8A91-02F766FC2D46}.Release|Any CPU.Build.0 = Release|Any CPU |
|||
{CA427ACE-098F-4883-8A91-02F766FC2D46}.Release|x64.ActiveCfg = Release|Any CPU |
|||
{CA427ACE-098F-4883-8A91-02F766FC2D46}.Release|x64.Build.0 = Release|Any CPU |
|||
{CA427ACE-098F-4883-8A91-02F766FC2D46}.Release|x86.ActiveCfg = Release|Any CPU |
|||
{CA427ACE-098F-4883-8A91-02F766FC2D46}.Release|x86.Build.0 = Release|Any CPU |
|||
EndGlobalSection |
|||
EndGlobal |
|||
@ -0,0 +1,35 @@ |
|||
// Licensed to the .NET Foundation under one or more agreements.
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
|||
// See the LICENSE file in the project root for more information.
|
|||
|
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.Extensions.Hosting; |
|||
|
|||
#if NETCOREAPP3_1
|
|||
#else
|
|||
using Microsoft.AspNetCore; |
|||
#endif
|
|||
|
|||
namespace MultiTargetFrameworks |
|||
{ |
|||
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(web => |
|||
{ |
|||
web.UseStartup<Startup>(); |
|||
}); |
|||
#else
|
|||
public static IWebHostBuilder CreateHostBuilder(string[] args) => |
|||
WebHost.CreateDefaultBuilder(args) |
|||
.UseStartup<Startup>(); |
|||
#endif
|
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
{ |
|||
"iisSettings": { |
|||
"windowsAuthentication": false, |
|||
"anonymousAuthentication": true, |
|||
"iisExpress": { |
|||
"applicationUrl": "http://localhost:5000", |
|||
"sslPort": 5001 |
|||
} |
|||
}, |
|||
"profiles": { |
|||
"IIS Express": { |
|||
"commandName": "IISExpress", |
|||
"launchBrowser": true, |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
} |
|||
}, |
|||
"multi-targetframeworks": { |
|||
"commandName": "Project", |
|||
"launchBrowser": true, |
|||
"applicationUrl": "https://localhost:5001;http://localhost:5000", |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,40 @@ |
|||
// Licensed to the .NET Foundation under one or more agreements.
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
|||
// See the LICENSE file in the project root for more information.
|
|||
|
|||
using Microsoft.AspNetCore.Builder; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.AspNetCore.Http; |
|||
using System.Reflection; |
|||
using System.Runtime.Versioning; |
|||
|
|||
namespace MultiTargetFrameworks |
|||
{ |
|||
public class Startup |
|||
{ |
|||
public Startup(IConfiguration configuration) |
|||
{ |
|||
Configuration = configuration; |
|||
} |
|||
|
|||
public IConfiguration Configuration { get; } |
|||
|
|||
public void ConfigureServices(IServiceCollection services) |
|||
{ |
|||
} |
|||
|
|||
public void Configure(IApplicationBuilder app) |
|||
{ |
|||
app.Use(async (httpContext, next) => |
|||
{ |
|||
#if NETCOREAPP3_1
|
|||
await httpContext.Response.WriteAsync(System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription); |
|||
#else
|
|||
var framework = Assembly.GetEntryAssembly()?.GetCustomAttribute<TargetFrameworkAttribute>()?.FrameworkName; |
|||
await httpContext.Response.WriteAsync(framework); |
|||
#endif
|
|||
}); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
{ |
|||
"Logging": { |
|||
"LogLevel": { |
|||
"Default": "Information", |
|||
"Microsoft": "Warning", |
|||
"Microsoft.Hosting.Lifetime": "Information" |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
{ |
|||
"Logging": { |
|||
"LogLevel": { |
|||
"Default": "Information", |
|||
"Microsoft": "Warning", |
|||
"Microsoft.Hosting.Lifetime": "Information" |
|||
} |
|||
}, |
|||
"AllowedHosts": "*" |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Web"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFrameworks>netcoreapp3.1;netcoreapp2.1</TargetFrameworks> |
|||
<RootNamespace>MultiTargetFrameworks</RootNamespace> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.1'"> |
|||
<PackageReference Include="Microsoft.AspNetCore.App" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,8 @@ |
|||
# tye application configuration file |
|||
# read all about it at https://github.com/dotnet/tye |
|||
name: multi-targetframeworks |
|||
services: |
|||
- name: multi-targetframeworks |
|||
project: multi-targetframeworks/multi-targetframeworks.csproj |
|||
bindings: |
|||
- port: 7000 |
|||
@ -0,0 +1,9 @@ |
|||
# tye application configuration file |
|||
# read all about it at https://github.com/dotnet/tye |
|||
name: multi-targetframeworks |
|||
services: |
|||
- name: multi-targetframeworks |
|||
project: multi-targetframeworks/multi-targetframeworks.csproj |
|||
buildProperties: |
|||
- name: TargetFramework |
|||
value: netcoreapp2.1 |
|||
@ -0,0 +1,9 @@ |
|||
# tye application configuration file |
|||
# read all about it at https://github.com/dotnet/tye |
|||
name: multi-targetframeworks |
|||
services: |
|||
- name: multi-targetframeworks |
|||
project: multi-targetframeworks/multi-targetframeworks.csproj |
|||
buildProperties: |
|||
- name: TargetFramework |
|||
value: netcoreapp3.1 |
|||
Loading…
Reference in new issue