728x90
반응형
728x170
▶ Program.cs
using System;
using System.IO;
using System.Text;
namespace TestProject
{
/// <summary>
/// 프로그램
/// </summary>
class Program
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Static
//////////////////////////////////////////////////////////////////////////////// Private
#region 프로그램 시작하기 - Main()
/// <summary>
/// 프로그램 시작하기
/// </summary>
private static void Main()
{
string sourceDirectoryPath = @"D:\DEVELOPMENT\ARCA\ARCA";
string sourceVersion = "4.5.2";
string targetVersion = "4.7.2";
Console.WriteLine($"SOURCE DIRECTORY PATH : {sourceDirectoryPath}");
if(!Directory.Exists(sourceDirectoryPath))
{
Console.WriteLine("NO SOURCE DIRECTORY FOUND");
return;
}
UTF8Encoding encoding = new UTF8Encoding(true);
string[] projectFilePathArray = Directory.GetFiles(sourceDirectoryPath, "*.csproj", SearchOption.AllDirectories);
if(projectFilePathArray.Length == 0)
{
Console.WriteLine("NO PROJECT FILE FOUND");
}
else
{
Console.WriteLine($"PROJECT FILE FOUND : {projectFilePathArray.Length}");
}
foreach(string projectFilePath in projectFilePathArray)
{
try
{
string content = File.ReadAllText(projectFilePath, encoding);
content = content.Replace
(
$"<TargetFrameworkVersion>v{sourceVersion}</TargetFrameworkVersion>",
$"<TargetFrameworkVersion>v{targetVersion}</TargetFrameworkVersion>"
);
File.WriteAllText(projectFilePath, content, encoding);
}
catch(Exception exception)
{
Console.WriteLine($"ERROR UPDATE PROJECT FILE : {Path.GetFileName(projectFilePath)}");
Console.WriteLine($" EXCEPTION : {exception}");
}
}
string[] appConfigFilePathArray = Directory.GetFiles(sourceDirectoryPath, "App.config", SearchOption.AllDirectories);
if(appConfigFilePathArray.Length == 0)
{
Console.WriteLine("NO APP.CONFIG FILE FOUND");
}
else
{
Console.WriteLine($"APP.CONFIG FILE FOUND : {appConfigFilePathArray.Length}");
}
foreach(string appConfigFilePath in appConfigFilePathArray)
{
try
{
string content = File.ReadAllText(appConfigFilePath, encoding);
content = content.Replace
(
$@"<supportedRuntime version=""v4.0"" sku="".NETFramework,Version=v{sourceVersion}""/>",
$@"<supportedRuntime version=""v4.0"" sku="".NETFramework,Version=v{sourceVersion}"" />"
);
content = content.Replace
(
$@"<supportedRuntime version=""v4.0"" sku="".NETFramework,Version=v{sourceVersion}"" />",
$@"<supportedRuntime version=""v4.0"" sku="".NETFramework,Version=v{targetVersion}"" />"
);
File.WriteAllText(appConfigFilePath, content, encoding);
}
catch(Exception exception)
{
Console.WriteLine($"ERROR UPDATE APP.CONFIG FILE : {Path.GetFileName(appConfigFilePath)}");
Console.WriteLine($" EXCEPTION : {exception}");
}
}
}
#endregion
}
}
728x90
반응형
그리드형(광고전용)
'C# > Common' 카테고리의 다른 글
[C#/COMMON] ManagementObjectSearcher 클래스 : 오디오 장치 열거하기 (0) | 2021.12.26 |
---|---|
[C#/COMMON] 누겟 설치 : FftSharp (0) | 2021.12.17 |
[C#/COMMON] WAV 파일 생성하기 (0) | 2021.12.08 |
[C#/COMMON] 누겟 설치 : PdfSharp (0) | 2021.11.29 |
[C#/COMMON] 누겟 설치 : CookComputing.XmlRPCv2 (0) | 2021.11.29 |
[C#/COMMON] 닷넷 프레임워크 소스 코드에서 닷넷 프레임워크 버전 일괄 변경하기 (0) | 2021.11.29 |
[C#/COMMON] Internet Explorer의 브라우저 에뮬레이션 모드 설정하기 (0) | 2021.11.23 |
[C#/COMMON] Process 클래스 : CloseMainWindow/Kill 메소드를 사용해 아웃룩 프로세스 제거하기 (0) | 2021.11.23 |
[C#/COMMON] 누겟 설치 : Newtonsoft.Json (0) | 2021.11.23 |
[C#/COMMON] WebUtility 클래스 : UrlEncode 정적 메소드를 사용해 URL 인코딩하기 (0) | 2021.11.21 |
[C#/COMMON] UdpClient 클래스 : WOL(Wake On LAN) 기능 사용하기 (0) | 2021.11.17 |
댓글을 달아 주세요