Skip to content

Commit

Permalink
Merge pull request #157 from TetsuOtter/156-windows-build
Browse files Browse the repository at this point in the history
Windows向けビルドを追加
  • Loading branch information
TetsuOtter authored Sep 23, 2024
2 parents 6812162 + 1789e33 commit 69c9382
Show file tree
Hide file tree
Showing 12 changed files with 330 additions and 125 deletions.
241 changes: 220 additions & 21 deletions .github/workflows/cd-action.yml

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions TRViS.IO.Tests/TRViS.IO.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.2.0"><IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PackageReference Include="NUnit.Analyzers" Version="4.3.0"><IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.2"><IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
4 changes: 2 additions & 2 deletions TRViS.IO/TRViS.IO.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

<ItemGroup>
<PackageReference Include="sqlite-net-pcl" Version="1.9.172" />
<PackageReference Include="SQLitePCLRaw.bundle_green" Version="2.1.8" />
<PackageReference Include="SQLitePCLRaw.bundle_green" Version="2.1.10" />
<PackageReference Include="System.Text.Json" Version="8.0.4" />
<PackageReference Include="TRViS.JsonModels" Version="1.0.1" />
<PackageReference Include="TRViS.JsonModels" Version="1.0.2" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.2.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.3.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.2" />
</ItemGroup>

Expand Down
4 changes: 4 additions & 0 deletions TRViS/DTAC/PageParts/TabButton.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ private void AppViewModel_PropertyChanged(object? sender, PropertyChangedEventAr
}
void OnWindowWidthChanged(double newValue)
{
if (newValue == 0)
{
return;
}
try
{
logger.Trace("newValue: {0}", newValue);
Expand Down
9 changes: 1 addition & 8 deletions TRViS/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,12 @@ public static MauiApp CreateMauiApp()
return builder.Build();
}

private static async void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
if (e.ExceptionObject is not Exception ex)
return;

logger.Fatal(ex, "UnhandledException");

if (!DirectoryPathProvider.CrashLogFileDirectory.Exists)
{
DirectoryPathProvider.CrashLogFileDirectory.Create();
}

await File.AppendAllTextAsync(CrashLogFilePath, $"{DateTime.Now:[yyyy/MM/dd HH:mm:ss]} {ex.Message}\n{ex.StackTrace}\n---\n(InnerException: {ex.InnerException})\n\n");
}
}

16 changes: 11 additions & 5 deletions TRViS/RootPages/SelectOnlineResourcePopup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ public SelectOnlineResourcePopup()
logger.Debug("New SelectOnlineResourcePopup()");
Size = new(480, 480);
RootStyles.BackgroundColor.Apply(this, Popup.ColorProperty);
#if WINDOWS
// 別ウィンドウを開くだけでも閉じてしまうため
CanBeDismissedByTappingOutsideOfPopup = false;
#endif

RootStyles.BackgroundBlackWhite.Apply(UrlInput, Button.BackgroundColorProperty);
RootStyles.TableTextColor.Apply(UrlInput, Button.TextColorProperty);
Expand Down Expand Up @@ -162,11 +166,13 @@ private async void DoLoad()
return;
}

AppLinkInfo appLinkInfo = new(
AppLinkInfo.FileType.Json,
Version: new(1,0),
ResourceUri: new(UrlInput.Text)
);
AppLinkInfo appLinkInfo = UrlInput.Text.StartsWith("trvis://")
? AppLinkInfo.FromAppLink(UrlInput.Text)
: new(
AppLinkInfo.FileType.Json,
Version: new(1,0),
ResourceUri: new(UrlInput.Text)
);
bool execResult = await InstanceManager.AppViewModel.HandleAppLinkUriAsync(appLinkInfo, CancellationToken.None);
if (execResult)
{
Expand Down
116 changes: 56 additions & 60 deletions TRViS/RootPages/SelectTrainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,67 +56,63 @@
</FlexLayout>


<Frame
Grid.Row="2">
<ScrollView>
<FlexLayout
Wrap="Wrap">
<Frame>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Label
Grid.Row="0"
FontSize="Subtitle"
Text="Work Group"/>
<ListView
Grid.Row="1"
ItemsSource="{Binding WorkGroupList}"
SelectedItem="{Binding SelectedWorkGroup, Mode=TwoWay}">
<ListView.ItemTemplate>
<DataTemplate
x:DataType="models:WorkGroup">
<TextCell
TextColor="{x:Static local:RootStyles.TableTextColor}"
DetailColor="{x:Static local:RootStyles.TableDetailColor}"
Text="{Binding Name}"/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</Frame>
<FlexLayout
Grid.Row="2"
Wrap="Wrap">
<Frame>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Label
Grid.Row="0"
FontSize="Subtitle"
Text="Work Group"/>
<ListView
Grid.Row="1"
ItemsSource="{Binding WorkGroupList}"
SelectedItem="{Binding SelectedWorkGroup, Mode=TwoWay}">
<ListView.ItemTemplate>
<DataTemplate
x:DataType="models:WorkGroup">
<TextCell
TextColor="{x:Static local:RootStyles.TableTextColor}"
DetailColor="{x:Static local:RootStyles.TableDetailColor}"
Text="{Binding Name}"/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</Frame>

<Frame>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Label
Grid.Row="0"
FontSize="Subtitle"
Text="Work"/>
<ListView
Grid.Row="1"
ItemsSource="{Binding WorkList}"
SelectedItem="{Binding SelectedWork, Mode=TwoWay}">
<ListView.ItemTemplate>
<DataTemplate
x:DataType="models:Work">
<TextCell
TextColor="{x:Static local:RootStyles.TableTextColor}"
DetailColor="{x:Static local:RootStyles.TableDetailColor}"
Text="{Binding Name}"/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</Frame>
</FlexLayout>
</ScrollView>
</Frame>
<Frame>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Label
Grid.Row="0"
FontSize="Subtitle"
Text="Work"/>
<ListView
Grid.Row="1"
ItemsSource="{Binding WorkList}"
SelectedItem="{Binding SelectedWork, Mode=TwoWay}">
<ListView.ItemTemplate>
<DataTemplate
x:DataType="models:Work">
<TextCell
TextColor="{x:Static local:RootStyles.TableTextColor}"
DetailColor="{x:Static local:RootStyles.TableDetailColor}"
Text="{Binding Name}"/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</Frame>
</FlexLayout>

</Grid>
</ContentPage>
4 changes: 2 additions & 2 deletions TRViS/Services/AppCenterService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static async Task<bool> ApplyCrashesSettingAsync(bool statusToBe)
#elif ANDROID
crashReport.AndroidDetails,
#else
crashReport.Exception,
"(No Detail)",
#endif
crashReport.StackTrace
);
Expand Down Expand Up @@ -203,7 +203,7 @@ static async Task InitCrashesSettings()
#elif ANDROID
crashReport.AndroidDetails,
#else
crashReport.Exception,
"(No Detail)",
#endif
crashReport.StackTrace
);
Expand Down
2 changes: 1 addition & 1 deletion TRViS/Services/LoggerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public static ErrorAttachmentLog[] GetErrorAttachmentsCallback(ErrorReport repor
#elif ANDROID
report.AndroidDetails,
#else
report.Exception,
"(No Detail)",
#endif
report.StackTrace
);
Expand Down
11 changes: 7 additions & 4 deletions TRViS/TRViS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks Condition="$([System.String]::IsNullOrEmpty('$(WITHOUT_ANDROID)'))">net8.0-android;</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('osx'))">$(TargetFrameworks);net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
<UseMauiNuGets>true</UseMauiNuGets>
<OutputType>Exe</OutputType>
Expand All @@ -26,6 +26,9 @@
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
</PropertyGroup>
<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows' and '$(RuntimeIdentifierOverride)' != ''">
<RuntimeIdentifier>$(RuntimeIdentifierOverride)</RuntimeIdentifier>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<WarningLevel>4</WarningLevel>
</PropertyGroup>
Expand All @@ -52,7 +55,7 @@
<ItemGroup>
<PackageReference
Include="Microsoft.Maui.Controls"
Version="8.0.70" />
Version="8.0.90" />
<PackageReference
Include="CommunityToolkit.Mvvm"
Version="8.2.2" />
Expand All @@ -66,10 +69,10 @@
Version="8.0.4" />
<PackageReference
Include="CommunityToolkit.Maui"
Version="9.0.2" />
Version="9.0.3" />
<PackageReference
Include="NLog"
Version="5.3.2" />
Version="5.3.4" />
<PackageReference
Include="Microsoft.AppCenter.Analytics"
Version="5.0.5" />
Expand Down
33 changes: 17 additions & 16 deletions tools/getThirdPartyLicenseJson.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import asdict, dataclass
import json
from os import makedirs
from os import makedirs, name as osName
from shutil import copyfile
from subprocess import PIPE, Popen
from os.path import dirname, basename, exists, join as joinPath
Expand All @@ -16,6 +16,8 @@
CSPROJ_PATH = dirname(__file__) + "/../TRViS/TRViS.csproj"
TIMEOUT_SEC = 2
ENC = "utf-8"
DOTNET_ENCODING = 'utf-8-sig' if osName == 'nt' else 'utf-8'

IGNORE_NS = "TRViS"

LICENSE_INFO_LIST_FILE_NAME = "license_list.json"
Expand Down Expand Up @@ -51,11 +53,11 @@ def getNugetGlobalPackagesDir() -> str:

async def getLicenseInfo(globalPackagesDir: str, packageInfo: PackageInfo) -> LicenseInfo:
packageNameLower = str.lower(packageInfo.PackageName)
resourcePath = f'{globalPackagesDir}{packageNameLower}/{packageInfo.ResolvedVersion}/{packageNameLower}.nuspec'
resourcePath = joinPath(globalPackagesDir, packageNameLower, packageInfo.ResolvedVersion, f'{packageNameLower}.nuspec')

metadata: ElementTree.Element = None
NUSPEC_XML_NAMESPACE = {}
async with aio_open(resourcePath, 'r') as stream:
async with aio_open(resourcePath, 'r', encoding=DOTNET_ENCODING) as stream:
root = ElementTree.fromstring(await stream.read())
if root is None:
return None
Expand Down Expand Up @@ -100,18 +102,17 @@ def getAndTrySetUniqueKey(dic: Dict[str, str], key: str) -> str:
return hashStr

async def getAndWriteFile(session: ClientSession, srcUrl: str, targetPath: str):
async with aio_open(targetPath, 'w') as f:
text = ''
async with session.get(srcUrl) as result:
if not result.ok:
raise EOFError(f'GET Request to {srcUrl} failed')
async with session.get(srcUrl) as result:
if not result.ok:
raise EOFError(f'GET Request to {srcUrl} failed')

text = await result.text()
async with aio_open(targetPath, 'wb') as f:
async for chunk in result.content.iter_chunked(4096):
await f.write(chunk)

result.close()
if not result.closed:
await result.wait_for_close()
await f.write(text)
result.close()
if not result.closed:
await result.wait_for_close()

async def dumpLicenseTextFileFromLicenseUrl(session: ClientSession, targetDir: str, licenseInfo: LicenseInfo, urlDic: Dict[str, str]):
url = licenseInfo.licenseUrl
Expand Down Expand Up @@ -145,7 +146,7 @@ async def dumpLicenseTextFileFromLicenseUrl(session: ClientSession, targetDir: s
await getAndWriteFile(session, url, licenseFilePath)

async def dumpLicenseTextFileFromLicenseExpression(session: ClientSession, licenseInfo: LicenseInfo, targetDir: str):
licenseList = [str(v) for v in re.split("\(|\)| ", licenseInfo.license) if (v != '' or v.isspace()) and v != "OR" and v != "AND"]
licenseList = [str(v) for v in re.split(r"\(|\)| ", licenseInfo.license) if (v != '' or v.isspace()) and v != "OR" and v != "AND"]
for licenseId in licenseList:
licenseFilePath = joinPath(targetDir, licenseId)
if exists(licenseFilePath):
Expand Down Expand Up @@ -176,7 +177,7 @@ def getFrameworkVersion(platform: str) -> str:
with Popen(["dotnet", "list", CSPROJ_PATH, "package"], stdout=PIPE) as p:
for line in p.stdout.readlines():
lineStr = line.decode(ENC)
frameworkVersionCheckResult = re.search(r"\[net\d+\.\d+-" + platform + r"\d+.\d+\]", lineStr)
frameworkVersionCheckResult = re.search(r"\[net\d+\.\d+-" + platform + r"\d+(.\d)+\]", lineStr)

if not frameworkVersionCheckResult:
continue
Expand All @@ -203,7 +204,7 @@ async def main(platform: str, targetDir: str) -> int:
continue
packages.append(PackageInfo(v[1].decode(ENC), v[-1].decode(ENC)))

globalPackagesDir = getNugetGlobalPackagesDir()
globalPackagesDir = getNugetGlobalPackagesDir().strip()
packageInfoList = await asyncio.gather(*[getLicenseInfo(globalPackagesDir, v) for v in packages if not v.PackageName.startswith(IGNORE_NS)])

urlDic = {}
Expand Down

0 comments on commit 69c9382

Please sign in to comment.