Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit 04ae7e5

Browse files
authored
upgrade to net6.0 (#693)
* upgrade to net6.0 * update release folder path Co-authored-by: Dmitrii Korolev <dmkorolev@microsoft.com>
1 parent ced2999 commit 04ae7e5

File tree

9 files changed

+84
-46
lines changed

9 files changed

+84
-46
lines changed

.azure-pipelines/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ stages:
2424
steps:
2525
- task: UseDotNet@2
2626
inputs:
27-
version: '3.1.x'
27+
version: '6.0.x'
2828
performMultiLevelLookup: true
2929

3030
- pwsh: |
@@ -72,7 +72,7 @@ stages:
7272

7373
- pwsh: |
7474
New-Item '$(Build.ArtifactStagingDirectory)/build' -Type Directory
75-
Get-ChildItem -Path 'src/ArmTemplates/bin/$(configuration)/netcoreapp3.1' -File | %{
75+
Get-ChildItem -Path 'src/ArmTemplates/bin/$(configuration)/net6.0' -File | %{
7676
Write-Host "Copy-Item -Path $_ -Destination '$(Build.ArtifactStagingDirectory)/build'"
7777
Copy-Item -Path $_ -Destination '$(Build.ArtifactStagingDirectory)/build'
7878
}

.dockerignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
**/.classpath
2+
**/.dockerignore
3+
**/.env
4+
**/.git
5+
**/.gitignore
6+
**/.project
7+
**/.settings
8+
**/.toolstarget
9+
**/.vs
10+
**/.vscode
11+
**/*.*proj.user
12+
**/*.dbmdl
13+
**/*.jfm
14+
**/azds.yaml
15+
**/bin
16+
**/charts
17+
**/docker-compose*
18+
**/Dockerfile*
19+
**/node_modules
20+
**/npm-debug.log
21+
**/obj
22+
**/secrets.dev.yaml
23+
**/values.dev.yaml
24+
LICENSE
25+
README.md

src/ArmTemplates/ArmTemplates.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
<TargetFramework>net6.0</TargetFramework>
66
<ProjectGuid>{B5183465-2BC1-4206-9C9F-5AC9615AC941}</ProjectGuid>
77
<LangVersion>latest</LangVersion>
88
<PackAsTool>true</PackAsTool>
99
<ToolCommandName>apim-templates</ToolCommandName>
1010
<Version>1.0.0</Version>
1111
<RootNamespace>$(SolutionName).$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace>
12+
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
13+
<DockerfileContext>..\..</DockerfileContext>
1214
</PropertyGroup>
1315

1416
<ItemGroup>
@@ -26,6 +28,7 @@
2628
<PackageReference Include="CommandLineParser" Version="2.8.0" />
2729
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="6.0.1" />
2830
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
31+
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.15.1" />
2932
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
3033
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
3134
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />

src/ArmTemplates/Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
2+
3+
FROM mcr.microsoft.com/dotnet/runtime:6.0 AS base
4+
WORKDIR /app
5+
6+
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
7+
WORKDIR /src
8+
COPY ["src/ArmTemplates/ArmTemplates.csproj", "src/ArmTemplates/"]
9+
RUN dotnet restore "src/ArmTemplates/ArmTemplates.csproj"
10+
COPY . .
11+
WORKDIR "/src/src/ArmTemplates"
12+
RUN dotnet build "ArmTemplates.csproj" -c Release -o /app/build
13+
14+
FROM build AS publish
15+
RUN dotnet publish "ArmTemplates.csproj" -c Release -o /app/publish
16+
17+
FROM base AS final
18+
WORKDIR /app
19+
COPY --from=publish /app/publish .
20+
ENTRYPOINT ["dotnet", "ArmTemplates.dll"]

src/ArmTemplates/Extractor/Utilities/Executable.cs

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@ namespace Microsoft.Azure.Management.ApiManagement.ArmTemplates.Extractor.Utilit
1313
{
1414
class Executable
1515
{
16-
string _arguments;
17-
string _exeName;
18-
bool _shareConsole;
19-
bool _streamOutput;
20-
readonly bool _visibleProcess;
21-
readonly string _workingDirectory;
16+
readonly string arguments;
17+
readonly string exeName;
18+
bool shareConsole;
19+
bool streamOutput;
20+
readonly bool visibleProcess;
21+
readonly string workingDirectory;
2222

2323
public Executable(string exeName, string arguments = null, bool streamOutput = true, bool shareConsole = false, bool visibleProcess = false, string workingDirectory = null)
2424
{
25-
this._exeName = exeName;
26-
this._arguments = arguments;
27-
this._streamOutput = streamOutput;
28-
this._shareConsole = shareConsole;
29-
this._visibleProcess = visibleProcess;
30-
this._workingDirectory = workingDirectory;
25+
this.exeName = exeName;
26+
this.arguments = arguments;
27+
this.streamOutput = streamOutput;
28+
this.shareConsole = shareConsole;
29+
this.visibleProcess = visibleProcess;
30+
this.workingDirectory = workingDirectory;
3131
}
3232

3333
public Process Process { get; private set; }
@@ -36,14 +36,14 @@ public async Task<int> RunAsync(Action<string> outputCallback = null, Action<str
3636
{
3737
var processInfo = new ProcessStartInfo
3838
{
39-
FileName = _exeName,
40-
Arguments = _arguments,
41-
CreateNoWindow = !this._visibleProcess,
42-
UseShellExecute = _shareConsole,
43-
RedirectStandardError = _streamOutput,
44-
RedirectStandardInput = _streamOutput,
45-
RedirectStandardOutput = _streamOutput,
46-
WorkingDirectory = this._workingDirectory ?? Environment.CurrentDirectory
39+
FileName = exeName,
40+
Arguments = arguments,
41+
CreateNoWindow = !this.visibleProcess,
42+
UseShellExecute = shareConsole,
43+
RedirectStandardError = streamOutput,
44+
RedirectStandardInput = streamOutput,
45+
RedirectStandardOutput = streamOutput,
46+
WorkingDirectory = this.workingDirectory ?? Environment.CurrentDirectory
4747
};
4848

4949
try
@@ -59,7 +59,7 @@ public async Task<int> RunAsync(Action<string> outputCallback = null, Action<str
5959
throw ex;
6060
}
6161

62-
if (this._streamOutput)
62+
if (this.streamOutput)
6363
{
6464
this.Process.OutputDataReceived += (s, e) => outputCallback?.Invoke(e.Data);
6565
this.Process.BeginOutputReadLine();
@@ -71,13 +71,16 @@ public async Task<int> RunAsync(Action<string> outputCallback = null, Action<str
7171
var exitCodeTask = this.Process.WaitForExitAsync();
7272

7373
if (timeout == null)
74-
return await exitCodeTask;
74+
{
75+
await exitCodeTask;
76+
return exitCodeTask.IsCompletedSuccessfully ? 0 : -1;
77+
}
7578
else
7679
{
7780
await Task.WhenAny(exitCodeTask, Task.Delay(timeout.Value));
7881

7982
if (exitCodeTask.IsCompleted)
80-
return exitCodeTask.Result;
83+
return exitCodeTask.IsCompletedSuccessfully ? 0 : -1;
8184
else
8285
{
8386
this.Process.Kill();

src/ArmTemplates/Properties/launchSettings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"profiles": {
33
"apimtemplate": {
44
"commandName": "Project"
5+
},
6+
"Docker": {
7+
"commandName": "Docker"
58
}
69
}
710
}

src/Dockerfile

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
Follow this guide for manually building and running the application
1313
1. git clone repository
1414
2. navigate to repo root
15-
3. build application using `dotnet build src/ArmTemplates/ArmTemplates.csproj` (netcore3.1 must be installed)
16-
4. navigate to built binaries using `cd .\src\ArmTemplates\bin\Debug\netcoreapp3.1\`
15+
3. build application using `dotnet build src/ArmTemplates/ArmTemplates.csproj` (net6.0 must be installed. Visit [Download .NET 6.0](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) for more information)
16+
4. navigate to built binaries using `cd .\src\ArmTemplates\bin\Debug\net6.0\`
1717
5. run ` dotnet .\ArmTemplates.dll --help` to view all available commands
1818
6. Investigate possible commands to run and choose desired
1919

tests/ArmTemplates.Tests/ArmTemplates.Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFramework>net6.0</TargetFramework>
55
<IsPackable>false</IsPackable>
66
<ProjectGuid>{7D0C17F8-C0F5-4678-A75F-EB1BE94E3A46}</ProjectGuid>
77
<RootNamespace>$(SolutionName).$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace>
@@ -15,7 +15,7 @@
1515
</ItemGroup>
1616

1717
<ItemGroup>
18-
<PackageReference Include="FluentAssertions" Version="6.5.1" />
18+
<PackageReference Include="FluentAssertions" Version="6.6.0" />
1919
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
2020
<PackageReference Include="Moq" Version="4.17.2" />
2121
<PackageReference Include="YamlDotNet" Version="11.2.1" />

0 commit comments

Comments
 (0)