Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump .net, small bugfixes #53

Merged
merged 14 commits into from
Mar 21, 2023
Merged
25 changes: 25 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/bin
**/charts
**/docker-compose*
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
59 changes: 59 additions & 0 deletions .github/workflows/dev_pwabuilder-ios(dev).yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy ASP.Net Core app to Azure Web App - pwabuilder-ios

on:
push:
branches:
- dev
workflow_dispatch:

jobs:
build:
runs-on: windows-latest

steps:
- uses: actions/checkout@v2

- name: Set up .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '7.x'
include-prerelease: true

- name: Build with dotnet
working-directory: ./Microsoft.PWABuilder.IOS.Web
run: dotnet build --configuration Release

- name: dotnet publish
working-directory: ./Microsoft.PWABuilder.IOS.Web
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp

- name: Upload artifact for deployment job
uses: actions/upload-artifact@v2
with:
name: .net-app
path: ${{env.DOTNET_ROOT}}/myapp

deploy:
runs-on: windows-latest
needs: build
environment:
name: 'dev'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v2
with:
name: .net-app

- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: 'pwabuilder-ios'
slot-name: 'dev'
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_0231B92C387E44F8B612C9B2A1A1E0E3 }}
package: .
39 changes: 39 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/Microsoft.PWABuilder.IOS.Web/bin/Debug/net7.0/Microsoft.PWABuilder.IOS.Web.dll",
"args": [],
"cwd": "${workspaceFolder}/Microsoft.PWABuilder.IOS.Web",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
},
{
"name": "Docker .NET Core Launch",
"type": "docker",
"request": "launch",
"preLaunchTask": "docker-run: debug",
"netCore": {
"appProject": "${workspaceFolder}/Microsoft.PWABuilder.IOS.Web/Microsoft.PWABuilder.IOS.Web.csproj"
}
}
]
}
97 changes: 97 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/Microsoft.PWABuilder.IOS.Web/Microsoft.PWABuilder.IOS.Web.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/Microsoft.PWABuilder.IOS.Web/Microsoft.PWABuilder.IOS.Web.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/Microsoft.PWABuilder.IOS.Web/Microsoft.PWABuilder.IOS.Web.csproj"
],
"problemMatcher": "$msCompile"
},
{
"type": "docker-build",
"label": "docker-build: debug",
"dependsOn": [
"build"
],
"dockerBuild": {
"tag": "pwabuilderios:dev",
"target": "base",
"dockerfile": "${workspaceFolder}/Microsoft.PWABuilder.IOS.Web/Dockerfile",
"context": "${workspaceFolder}",
"pull": true
},
"netCore": {
"appProject": "${workspaceFolder}/Microsoft.PWABuilder.IOS.Web/Microsoft.PWABuilder.IOS.Web.csproj"
}
},
{
"type": "docker-build",
"label": "docker-build: release",
"dependsOn": [
"build"
],
"dockerBuild": {
"tag": "pwabuilderios:latest",
"dockerfile": "${workspaceFolder}/Microsoft.PWABuilder.IOS.Web/Dockerfile",
"context": "${workspaceFolder}",
"pull": true
},
"netCore": {
"appProject": "${workspaceFolder}/Microsoft.PWABuilder.IOS.Web/Microsoft.PWABuilder.IOS.Web.csproj"
}
},
{
"type": "docker-run",
"label": "docker-run: debug",
"dependsOn": [
"docker-build: debug"
],
"dockerRun": {},
"netCore": {
"appProject": "${workspaceFolder}/Microsoft.PWABuilder.IOS.Web/Microsoft.PWABuilder.IOS.Web.csproj",
"enableDebugging": true
}
},
{
"type": "docker-run",
"label": "docker-run: release",
"dependsOn": [
"docker-build: release"
],
"dockerRun": {},
"netCore": {
"appProject": "${workspaceFolder}/Microsoft.PWABuilder.IOS.Web/Microsoft.PWABuilder.IOS.Web.csproj"
}
}
]
}
29 changes: 29 additions & 0 deletions Microsoft.PWABuilder.IOS.Web/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 5000

ENV ASPNETCORE_URLS=http://+:5000

# Creates a non-root user with an explicit UID and adds permission to access the /app folder
# For more info, please refer to https://aka.ms/vscode-docker-dotnet-configure-containers
RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
USER appuser

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["Microsoft.PWABuilder.IOS.Web/Microsoft.PWABuilder.IOS.Web.csproj", "Microsoft.PWABuilder.IOS.Web/"]
RUN dotnet restore "Microsoft.PWABuilder.IOS.Web/Microsoft.PWABuilder.IOS.Web.csproj"
COPY . .
WORKDIR "/src/Microsoft.PWABuilder.IOS.Web"
RUN dotnet build "Microsoft.PWABuilder.IOS.Web.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Microsoft.PWABuilder.IOS.Web.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Microsoft.PWABuilder.IOS.Web.dll"]

USER root
RUN chown -R appuser /app
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions Microsoft.PWABuilder.IOS.Web/Models/XcodeProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void Load()

public XcodeFile GetFile(string fileName)
{
var file = this.files.SingleOrDefault(f => string.Equals(f.Name, fileName, StringComparison.OrdinalIgnoreCase));
var file = this.files.FirstOrDefault(f => string.Equals(f.Name, fileName, StringComparison.OrdinalIgnoreCase));
if (file == null)
{
throw new FileNotFoundException("Unable to find file " + fileName);
Expand All @@ -62,7 +62,7 @@ public XcodeFile GetFile(string fileName)

public XcodeFile GetFileByPath(string partialOrCompletePath)
{
var file = this.files.SingleOrDefault(f => f.ItemPath.Contains(partialOrCompletePath, StringComparison.OrdinalIgnoreCase));
var file = this.files.FirstOrDefault(f => f.ItemPath.Contains(partialOrCompletePath, StringComparison.OrdinalIgnoreCase));
if (file == null)
{
throw new FileNotFoundException("Unable to find file with path " + partialOrCompletePath);
Expand All @@ -73,7 +73,7 @@ public XcodeFile GetFileByPath(string partialOrCompletePath)

public XcodeFolder GetFolder(string folderName)
{
var folder = this.folders.SingleOrDefault(f => string.Equals(f.Name, folderName, StringComparison.OrdinalIgnoreCase));
var folder = this.folders.FirstOrDefault(f => string.Equals(f.Name, folderName, StringComparison.OrdinalIgnoreCase));
if (folder == null)
{
throw new FileNotFoundException("Unable to find folder " + folder);
Expand Down
15 changes: 7 additions & 8 deletions Microsoft.PWABuilder.IOS.Web/Models/XcodePwaShellProject.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
using Microsoft.PWABuilder.IOS.Web.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.IO;

namespace Microsoft.PWABuilder.IOS.Web.Models
{
/// <summary>
/// Models the pwa-shell Xcode project that serves as the template for generated PWA packages.
/// </summary>
public class XcodePwaShellProject : XcodeProject
/// <summary>
/// Models the pwa-shell Xcode project that serves as the template for generated PWA packages.
/// </summary>
public class XcodePwaShellProject : XcodeProject
{
private readonly IOSAppPackageOptions.Validated options;
private readonly string macSafeProjectName;
Expand Down Expand Up @@ -178,8 +177,8 @@ private void UpdateProjectFolderReferences()
var oldDirName = "pwa-shell";

GetFile("Podfile").Replace(oldDirName, macSafeProjectName);
GetFileByPath("project.xcworkspace\\contents.xcworkspacedata").Replace(oldDirName, macSafeProjectName);
GetFileByPath("pwa-shell.xcworkspace\\contents.xcworkspacedata").Replace(oldDirName, macSafeProjectName);
GetFileByPath(Path.Combine("project.xcworkspace", "contents.xcworkspacedata")).Replace(oldDirName, macSafeProjectName);
GetFileByPath(Path.Combine("pwa-shell.xcworkspace", "contents.xcworkspacedata")).Replace(oldDirName, macSafeProjectName);
GetFile("pwa-shell.xcscheme").Replace(oldDirName, macSafeProjectName);

// project.pbxproj has some references to the old directory name.
Expand Down
6 changes: 3 additions & 3 deletions Microsoft.PWABuilder.IOS.Web/Services/ImageGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private IEnumerable<ImageSource> GetImageSourcesForTargetSizes(WebAppManifestCon
private async Task<List<string>> TryWriteImageSourcesToDirectory(IEnumerable<ImageSource> sources, string outputDirectory)
{
var imageFilePaths = new List<string>(40);
var launchIconDirectory = Path.Combine(outputDirectory, "pwa-shell\\Assets.xcassets\\LaunchIcon.imageset");
var launchIconDirectory = Path.Combine(outputDirectory, Path.Combine("pwa-shell", "Assets.xcassets", "LaunchIcon.imageset"));
foreach (var source in sources)
{
var filePath = await TryWriteImageSourceToDirectory(source, outputDirectory);
Expand Down Expand Up @@ -196,7 +196,7 @@ private async Task<List<string>> TryWriteImageSourcesToDirectory(IEnumerable<Ima
(action: () => TryOpenZipEntry(source.GeneratedImageSource), description: source.GeneratedImageSource?.FullName)
};

var appIconDirectory = Path.Combine(outputDirectory, "pwa-shell\\Assets.xcassets\\AppIcon.appiconset");
var appIconDirectory = Path.Combine(outputDirectory, Path.Combine("pwa-shell", "Assets.xcassets", "AppIcon.appiconset"));
foreach (var (action, description) in streamOpeners)
{
using var stream = await action();
Expand Down Expand Up @@ -234,7 +234,7 @@ private async Task<List<string>> TryWriteImageSourcesToDirectory(IEnumerable<Ima
}
catch (Exception fetchError)
{
logger.LogWarning(fetchError, "Attempted to fetch image at {url}, but download failed with exception");
logger.LogWarning(fetchError, "Attempted to fetch image at {url}, but download failed with exception", imageUri);
return null;
}

Expand Down
6 changes: 3 additions & 3 deletions Microsoft.PWABuilder.IOS.Web/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
}
},
"AppSettings": {
"IOSSourceCodePath": "bin\\Debug\\net5.0\\Resources\\ios-project-src",
"NextStepsPath": "bin\\Debug\\net5.0\\Resources\\next-steps.html",
"IOSSourceCodePath": "bin/Debug/net7.0/Resources/ios-project-src",
"NextStepsPath": "bin/Debug/net7.0/Resources/next-steps.html",
"ImageGeneratorApiUrl": "https://appimagegenerator-pre.azurewebsites.net/api/image"
}
}
}
4 changes: 2 additions & 2 deletions Microsoft.PWABuilder.IOS.Web/appsettings.Production.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"AppSettings": {
"IOSSourceCodePath": "Resources\\ios-project-src",
"NextStepsPath": "Resources\\next-steps.html",
"IOSSourceCodePath": "Resources/ios-project-src",
"NextStepsPath": "Resources/next-steps.html",
"ImageGeneratorApiUrl": "https://appimagegenerator-prod.azurewebsites.net/api/image"
}
}
16 changes: 16 additions & 0 deletions docker-compose.debug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Please refer https://aka.ms/HTTPSinContainer on how to setup an https developer certificate for your ASP .NET Core service.

version: '3.4'

services:
microsoftpwabuilderiosweb:
image: microsoftpwabuilderiosweb
build:
context: .
dockerfile: Microsoft.PWABuilder.IOS.Web/Dockerfile
ports:
- 5000:5000
environment:
- ASPNETCORE_ENVIRONMENT=Development
volumes:
- ~/.vsdbg:/remote_debugger:rw
Loading