Skip to content

Commit

Permalink
Migrate Agent.Service to .NET 6
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisRumyantsev committed Mar 26, 2024
1 parent 03113b6 commit 76b306d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 51 deletions.
3 changes: 1 addition & 2 deletions src/Agent.Service/Windows/AgentService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT License.

using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
Expand Down Expand Up @@ -352,6 +351,6 @@ private enum AgentUpdateResult
private static extern bool SetConsoleCtrlHandler(ConsoleCtrlDelegate HandlerRoutine, bool Add);

// Delegate type to be used as the Handler Routine for SetConsoleCtrlHandler
delegate Boolean ConsoleCtrlDelegate(uint CtrlType);
private delegate bool ConsoleCtrlDelegate(uint CtrlType);
}
}
53 changes: 12 additions & 41 deletions src/Agent.Service/Windows/AgentService.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project ToolsVersion="17.0" Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand All @@ -12,9 +10,12 @@
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>FinalPublicKey.snk</AssemblyOriginatorKeyFile>
<DelaySign>true</DelaySign>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworkVersion>v6.0.28</TargetFrameworkVersion>
<RuntimeIdentifier>$(PackageRuntime)</RuntimeIdentifier>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -39,60 +40,30 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AgentService.cs">
<Compile Update="AgentService.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="AgentService.Designer.cs">
<Compile Update="AgentService.Designer.cs">
<DependentUpon>AgentService.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Resource.Designer.cs">
<Compile Update="Resource.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resource.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="FinalPublicKey.snk" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resource.de-de.resx">
</EmbeddedResource>
<EmbeddedResource Include="Resource.es-es.resx">
</EmbeddedResource>
<EmbeddedResource Include="Resource.fr-fr.resx">
</EmbeddedResource>
<EmbeddedResource Include="Resource.it-IT.resx">
</EmbeddedResource>
<EmbeddedResource Include="Resource.ja-jp.resx">
</EmbeddedResource>
<EmbeddedResource Include="Resource.ko-KR.resx">
</EmbeddedResource>
<EmbeddedResource Include="Resource.resx">
<EmbeddedResource Update="Resource.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resource.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="Resource.ru-RU.resx">
</EmbeddedResource>
<EmbeddedResource Include="Resource.zh-CN.resx">
</EmbeddedResource>
<EmbeddedResource Include="Resource.zh-TW.resx">
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<PackageReference Include="System.ServiceProcess.ServiceController" Version="6.0.1" />
</ItemGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
6 changes: 0 additions & 6 deletions src/Agent.Service/Windows/App.config

This file was deleted.

5 changes: 4 additions & 1 deletion src/Agent.Service/Windows/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
// Licensed under the MIT License.

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Resources;
using System.Runtime.Versioning;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
Expand All @@ -16,6 +17,8 @@
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: NeutralResourcesLanguage("en")]
[assembly: SupportedOSPlatform("windows")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
Expand Down
10 changes: 9 additions & 1 deletion src/dir.proj
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,21 @@
SkipNonExistentProjects="false"
StopOnFirstFailure="true" />

<MSBuild Targets="Restore"
BuildInParallel="false"
Projects="Agent.Service/Windows/AgentService.csproj"
SkipNonExistentProjects="false"
StopOnFirstFailure="true"
Properties="PackageRuntime=$(PackageRuntime);RuntimeIdentifier=$(PackageRuntime)"
Condition="'$(PackageRuntime)' == 'win-x64' Or '$(PackageRuntime)' == 'win-x86'" />

<MSBuild Targets="Publish"
BuildInParallel="false"
Projects="@(ProjectFiles)"
SkipNonExistentProjects="false"
StopOnFirstFailure="true"
Properties="Configuration=$(BUILDCONFIG);PackageRuntime=$(PackageRuntime);Version=$(AgentVersion);RuntimeIdentifier=$(PackageRuntime);PublishDir=$(LayoutRoot)/bin;TreatWarningsAsErrors=$(TreatWarningsAsErrors)" />
<Exec Command="%22$(DesktopMSBuild)%22 Agent.Service/Windows/AgentService.csproj /p:Configuration=$(BUILDCONFIG) /p:OutputPath=%22$(LayoutRoot)/bin%22 /p:TreatWarningsAsErrors=$(TreatWarningsAsErrors)" ConsoleToMSBuild="true" Condition="'$(PackageRuntime)' == 'win-x64' Or '$(PackageRuntime)' == 'win-x86'" />
<Exec Command="%22$(DesktopMSBuild)%22 Agent.Service/Windows/AgentService.csproj /p:PackageRuntime=$(PackageRuntime) /p:Configuration=$(BUILDCONFIG) /p:OutputPath=%22$(LayoutRoot)/bin%22" ConsoleToMSBuild="true" Condition="'$(PackageRuntime)' == 'win-x64' Or '$(PackageRuntime)' == 'win-x86'" />
</Target>

<Target Name="TestL0" DependsOnTargets="GenerateConstant">
Expand Down

0 comments on commit 76b306d

Please sign in to comment.