Skip to content
This repository has been archived by the owner on Dec 17, 2021. It is now read-only.

Commit

Permalink
- Fix NuGet package failing on users using folders with space
Browse files Browse the repository at this point in the history
- Fixing inconsistent behavior in package referencing in Android project (fixed in sample)
  • Loading branch information
Daddoon committed Oct 11, 2019
1 parent ce75279 commit bf13f6e
Show file tree
Hide file tree
Showing 18 changed files with 1,060 additions and 1,000 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@

<PropertyGroup>
<BlazorMobileBuildAndroidDir Condition="'$(BlazorMobileBuildAndroidDir)' == ''">$(MSBuildThisFileDirectory)netcoreapp3.0/</BlazorMobileBuildAndroidDir>
<BlazorMobileBuildAndroidFileExe>dotnet &quot;$(BlazorMobileBuildAndroidDir)BlazorMobile.Build.Android.dll&quot;</BlazorMobileBuildAndroidFileExe>
<BlazorMobileBuildAndroidInput>&quot;$(MSBuildProjectFullPath)&quot;</BlazorMobileBuildAndroidInput>
<BlazorMobileBuildAndroidFileExe>dotnet &quot;$([MSBuild]::Escape($(BlazorMobileBuildAndroidDir)BlazorMobile.Build.Android.dll))&quot;</BlazorMobileBuildAndroidFileExe>
<BlazorMobileBuildAndroidInput>&quot;$([MSBuild]::Escape($(MSBuildProjectFullPath)))&quot;</BlazorMobileBuildAndroidInput>
<!-- The current line below is expected. We do not search about the real obj intermediateOutputPath -->
<!-- if it's different but just having an ignored directory for version control BUT not prefixed by some Android Debug or SDK version at build -->
<!-- for injecting somme Android Assets with a consistent path -->
<BlazorMobileBuildAndroidIntermediateOutputPath>$(MSBuildProjectDirectory)/obj/</BlazorMobileBuildAndroidIntermediateOutputPath>
<BlazorMobileBuildAndroidIntermediateOutputPath>$([MSBuild]::Escape($(MSBuildProjectDirectory)/obj/))</BlazorMobileBuildAndroidIntermediateOutputPath>
</PropertyGroup>

<Target Name="_InjectBlazorMobileIFrameListenerWebExtension" BeforeTargets="CoreCompile">
<Exec Command="$(BlazorMobileBuildAndroidFileExe) inject-iframe-listener-webextension --input $(BlazorMobileBuildAndroidInput) --package-dir $(BlazorMobileBuildAndroidDir) --intermediate-output-path $(BlazorMobileBuildAndroidIntermediateOutputPath)" />
<Exec Command="$(BlazorMobileBuildAndroidFileExe) inject-iframe-listener-webextension --input $(BlazorMobileBuildAndroidInput) --package-dir &quot;$([MSBuild]::Escape($(BlazorMobileBuildAndroidDir)))&quot; --intermediate-output-path &quot;$(BlazorMobileBuildAndroidIntermediateOutputPath)&quot;" />
</Target>

<Target Name="InjectBlazorMobileIFrameListenerWebExtension" DependsOnTargets="_InjectBlazorMobileIFrameListenerWebExtension" BeforeTargets="CoreCompile">
Expand Down
38 changes: 38 additions & 0 deletions src/BlazorMobile.Build/Cli/Helper/PathHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace BlazorMobile.Build.Cli.Helper
{
public static class PathHelper
{
private static string ReplaceLastOccurrence(string Source, string Find, string Replace)
{
int place = Source.LastIndexOf(Find);

if (place == -1)
return Source;

string result = Source.Remove(place, Find.Length).Insert(place, Replace);
return result;
}

/// <summary>
/// CMD and MSBuild seems to escape quote sometime instead
/// of escaping the path delimiter, even if using MSBuild::Escape
/// function. This method replace and ending quote by a path
/// delimiter instead, for fixing this possible behavior
/// </summary>
/// <returns></returns>
public static string MSBuildQuoteFixer(string input)
{
if (input.EndsWith('"'))
{
input = ReplaceLastOccurrence(input, "\"", Path.DirectorySeparatorChar.ToString());
}

return input;
}
}
}
5 changes: 4 additions & 1 deletion src/BlazorMobile.Build/Core/BlazorProjectIndexHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BlazorMobile.Build.Core.Helper;
using BlazorMobile.Build.Cli.Helper;
using BlazorMobile.Build.Core.Helper;
using System;
using System.Collections.Generic;
using System.Diagnostics;
Expand All @@ -14,6 +15,8 @@ internal static class BlazorProjectIndexHelper
{
public static void FindAndReplace(string inputDir, string projectFile)
{
inputDir = PathHelper.MSBuildQuoteFixer(inputDir);

string wwwFolder = inputDir + "/wwwroot";

if (!Directory.Exists(wwwFolder))
Expand Down
9 changes: 6 additions & 3 deletions src/BlazorMobile.Build/Core/NativeBindingsHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BlazorMobile.Build.Core.NativeBindings;
using BlazorMobile.Build.Cli.Helper;
using BlazorMobile.Build.Core.NativeBindings;
using System;
using System.Collections.Generic;
using System.IO;
Expand Down Expand Up @@ -83,12 +84,12 @@ public static string GetIntermediateOutputPath(string projectFile, string baseIn
if (Path.IsPathRooted(trimedPath))
{
//Absolute path case
return baseIntermediateOutputPath + BlazorMobileProxyClassFolderName;
return Path.Combine(baseIntermediateOutputPath, BlazorMobileProxyClassFolderName);
}
else
{
//Relative path case (the default one)
return Path.GetDirectoryName(projectFile) + Path.DirectorySeparatorChar + baseIntermediateOutputPath + BlazorMobileProxyClassFolderName;
return Path.Combine(Path.GetDirectoryName(projectFile), baseIntermediateOutputPath, BlazorMobileProxyClassFolderName);
}
}

Expand All @@ -102,6 +103,8 @@ private static void CleanIntermediateOutputPath(string intermediateOutputPath)

public static void GenerateNativeBindings(string projectFile, string intermediateOutputPath)
{
intermediateOutputPath = PathHelper.MSBuildQuoteFixer(intermediateOutputPath);

if (string.IsNullOrEmpty(projectFile) || !File.Exists(projectFile))
{
throw new InvalidOperationException("The specified project is invalid or does not exist");
Expand Down
6 changes: 5 additions & 1 deletion src/BlazorMobile.Build/Core/PublishAndZipHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using BlazorMobile.Build.Cli.Helper;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
Expand All @@ -23,6 +24,9 @@ public static void PublishAndZip(string inputFile, string outputPath, string dis

artifactName = Path.GetFileNameWithoutExtension(inputFile);

outputPath = PathHelper.MSBuildQuoteFixer(outputPath);
distDir = PathHelper.MSBuildQuoteFixer(distDir);

//Warning invalid outputPath
if (string.IsNullOrEmpty(outputPath))
{
Expand Down
22 changes: 11 additions & 11 deletions src/BlazorMobile.Build/tools/GenerateBlazorMobileBuild.targets
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

<PropertyGroup>
<BlazorMobileBuildDir Condition="'$(BlazorMobileBuildDir)' == ''">$(MSBuildThisFileDirectory)netcoreapp3.0/</BlazorMobileBuildDir>
<BlazorMobileBuildFileExe>dotnet &quot;$(BlazorMobileBuildDir)BlazorMobile.Build.dll&quot;</BlazorMobileBuildFileExe>
<BlazorMobileBuildOutput>&quot;$(MSBuildProjectDirectory)/bin&quot;</BlazorMobileBuildOutput>
<BlazorMobileBuildDistDir>&quot;$(OutDir)/dist&quot;</BlazorMobileBuildDistDir>
<BlazorMobileBuildInput>&quot;$(MSBuildProjectFullPath)&quot;</BlazorMobileBuildInput>
<BlazorMobileBuildFileExe>dotnet &quot;$([MSBuild]::Escape($(BlazorMobileBuildDir)BlazorMobile.Build.dll))&quot;</BlazorMobileBuildFileExe>
<BlazorMobileBuildOutput>&quot;$([MSBuild]::Escape($(MSBuildProjectDirectory)/bin))&quot;</BlazorMobileBuildOutput>
<BlazorMobileBuildDistDir>&quot;$([MSBuild]::Escape($(OutDir)/dist))&quot;</BlazorMobileBuildDistDir>
<BlazorMobileBuildInput>&quot;$([MSBuild]::Escape($(MSBuildProjectFullPath)))&quot;</BlazorMobileBuildInput>
</PropertyGroup>

<Target Name="GenerateBlazorMobileBuild" AfterTargets="_BlazorBuildReport">
Expand All @@ -24,9 +24,9 @@

<PropertyGroup>
<BlazorMobileBuildServerDir Condition="'$(BlazorMobileBuildServerDir)' == ''">$(MSBuildThisFileDirectory)netcoreapp3.0/</BlazorMobileBuildServerDir>
<BlazorMobileBuildServerdFileExe>dotnet &quot;$(BlazorMobileBuildServerDir)BlazorMobile.Build.dll&quot;</BlazorMobileBuildServerdFileExe>
<BlazorMobileBuildServerInput>&quot;$(MSBuildProjectDirectory)&quot;</BlazorMobileBuildServerInput>
<BlazorMobileBuildServerProjectInput>&quot;$(MSBuildProjectFullPath)&quot;</BlazorMobileBuildServerProjectInput>
<BlazorMobileBuildServerdFileExe>dotnet &quot;$([MSBuild]::Escape($(BlazorMobileBuildServerDir)BlazorMobile.Build.dll))&quot;</BlazorMobileBuildServerdFileExe>
<BlazorMobileBuildServerInput>&quot;$([MSBuild]::Escape($(MSBuildProjectDirectory)))&quot;</BlazorMobileBuildServerInput>
<BlazorMobileBuildServerProjectInput>&quot;$([MSBuild]::Escape($(MSBuildProjectFullPath)))&quot;</BlazorMobileBuildServerProjectInput>
</PropertyGroup>

<Target Name="GenerateBlazorMobileBuildServer" BeforeTargets="BeforeBuild">
Expand All @@ -38,13 +38,13 @@

<PropertyGroup>
<BlazorMobileBuildNativeProxyDir Condition="'$(BlazorMobileBuildNativeProxyDir)' == ''">$(MSBuildThisFileDirectory)netcoreapp3.0/</BlazorMobileBuildNativeProxyDir>
<BlazorMobileBuildNativeProxyFileExe>dotnet &quot;$(BlazorMobileBuildNativeProxyDir)BlazorMobile.Build.dll&quot;</BlazorMobileBuildNativeProxyFileExe>
<BlazorMobileBuildNativeProxyInput>&quot;$(MSBuildProjectFullPath)&quot;</BlazorMobileBuildNativeProxyInput>
<BlazorMobileBuildNativeProxyIntermediateOutputPath>$(IntermediateOutputPath)</BlazorMobileBuildNativeProxyIntermediateOutputPath>
<BlazorMobileBuildNativeProxyFileExe>dotnet &quot;$([MSBuild]::Escape($(BlazorMobileBuildNativeProxyDir)BlazorMobile.Build.dll))&quot;</BlazorMobileBuildNativeProxyFileExe>
<BlazorMobileBuildNativeProxyInput>&quot;$([MSBuild]::Escape($(MSBuildProjectFullPath)))&quot;</BlazorMobileBuildNativeProxyInput>
<BlazorMobileBuildNativeProxyIntermediateOutputPath>$([MSBuild]::Escape($(IntermediateOutputPath)))</BlazorMobileBuildNativeProxyIntermediateOutputPath>
</PropertyGroup>

<Target Name="_AddGeneratedNativeProxyClass" BeforeTargets="CoreCompile">
<Exec Command="$(BlazorMobileBuildNativeProxyFileExe) auto-generate-native-bindings --input $(BlazorMobileBuildNativeProxyInput) --intermediate-output-path $(BlazorMobileBuildNativeProxyIntermediateOutputPath)" />
<Exec Command="$(BlazorMobileBuildNativeProxyFileExe) auto-generate-native-bindings --input $(BlazorMobileBuildNativeProxyInput) --intermediate-output-path &quot;$(BlazorMobileBuildNativeProxyIntermediateOutputPath)&quot;" />
</Target>

<Target Name="AddGeneratedNativeProxyClass" DependsOnTargets="_AddGeneratedNativeProxyClass" BeforeTargets="CoreCompile">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="BlazorMobile.Build.Android">
<Version>3.0.11-preview9.19465.2</Version>
<Version>3.0.12-preview9.19465.2</Version>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Blazor">
<Version>3.0.0-preview9.19465.2</Version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="BlazorMobile.Build" Version="3.0.11-preview9.19465.2" />
<PackageReference Include="BlazorMobile.Build" Version="3.0.12-preview9.19465.2" />
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview9.19465.2" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview9.19465.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.DevServer" Version="3.0.0-preview9.19465.2" />
Expand Down
2 changes: 1 addition & 1 deletion src/BlazorMobile.NuGet/BlazorMobile.NuGet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</ItemGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="set nugetVersion=3.0.11-preview9.19465.2&#xD;&#xA;echo NuGet artifact version is: %25nugetVersion%25&#xD;&#xA;&#xD;&#xA;nuget pack .\..\BlazorMobile\BlazorMobile.nuspec -Version &quot;%25nugetVersion%25&quot; -OutputDirectory .\artifacts&#xD;&#xA;nuget pack .\..\BlazorMobile\BlazorMobile.Common.nuspec -Version &quot;%25nugetVersion%25&quot; -OutputDirectory .\artifacts&#xD;&#xA;nuget pack .\..\BlazorMobile\BlazorMobile.Web.nuspec -Version &quot;%25nugetVersion%25&quot; -OutputDirectory .\artifacts&#xD;&#xA;nuget pack .\..\BlazorMobile\BlazorMobile.ElectronNET.nuspec -Version &quot;%25nugetVersion%25&quot; -OutputDirectory .\artifacts&#xD;&#xA;nuget pack .\..\BlazorMobile.Build\BlazorMobile.Build.nuspec -Version &quot;%25nugetVersion%25&quot; -OutputDirectory .\artifacts&#xD;&#xA;nuget pack .\..\BlazorMobile.Build.Android\BlazorMobile.Build.Android.nuspec -Version &quot;%25nugetVersion%25&quot; -OutputDirectory .\artifacts&#xD;&#xA;&#xD;&#xA;cd .\..\BlazorMobile.Templates\content&#xD;&#xA;&#xD;&#xA;FOR /d /r . %25%25d IN (bin) DO @IF EXIST &quot;%25%25d&quot; rd /s /q &quot;%25%25d&quot;&#xD;&#xA;FOR /d /r . %25%25d IN (_bin) DO @IF EXIST &quot;%25%25d&quot; rd /s /q &quot;%25%25d&quot;&#xD;&#xA;FOR /d /r . %25%25d IN (obj) DO @IF EXIST &quot;%25%25d&quot; rd /s /q &quot;%25%25d&quot;&#xD;&#xA;&#xD;&#xA;cd .\..\..\BlazorMobile.NuGet&#xD;&#xA;&#xD;&#xA;nuget pack .\..\BlazorMobile.Templates\BlazorMobile.Templates.nuspec -Version &quot;%25nugetVersion%25&quot; -OutputDirectory .\artifacts" />
<Exec Command="set nugetVersion=3.0.12-preview9.19465.2&#xD;&#xA;echo NuGet artifact version is: %25nugetVersion%25&#xD;&#xA;&#xD;&#xA;nuget pack .\..\BlazorMobile\BlazorMobile.nuspec -Version &quot;%25nugetVersion%25&quot; -OutputDirectory .\artifacts&#xD;&#xA;nuget pack .\..\BlazorMobile\BlazorMobile.Common.nuspec -Version &quot;%25nugetVersion%25&quot; -OutputDirectory .\artifacts&#xD;&#xA;nuget pack .\..\BlazorMobile\BlazorMobile.Web.nuspec -Version &quot;%25nugetVersion%25&quot; -OutputDirectory .\artifacts&#xD;&#xA;nuget pack .\..\BlazorMobile\BlazorMobile.ElectronNET.nuspec -Version &quot;%25nugetVersion%25&quot; -OutputDirectory .\artifacts&#xD;&#xA;nuget pack .\..\BlazorMobile.Build\BlazorMobile.Build.nuspec -Version &quot;%25nugetVersion%25&quot; -OutputDirectory .\artifacts&#xD;&#xA;nuget pack .\..\BlazorMobile.Build.Android\BlazorMobile.Build.Android.nuspec -Version &quot;%25nugetVersion%25&quot; -OutputDirectory .\artifacts&#xD;&#xA;&#xD;&#xA;cd .\..\BlazorMobile.Templates\content&#xD;&#xA;&#xD;&#xA;FOR /d /r . %25%25d IN (bin) DO @IF EXIST &quot;%25%25d&quot; rd /s /q &quot;%25%25d&quot;&#xD;&#xA;FOR /d /r . %25%25d IN (_bin) DO @IF EXIST &quot;%25%25d&quot; rd /s /q &quot;%25%25d&quot;&#xD;&#xA;FOR /d /r . %25%25d IN (obj) DO @IF EXIST &quot;%25%25d&quot; rd /s /q &quot;%25%25d&quot;&#xD;&#xA;&#xD;&#xA;cd .\..\..\BlazorMobile.NuGet&#xD;&#xA;&#xD;&#xA;nuget pack .\..\BlazorMobile.Templates\BlazorMobile.Templates.nuspec -Version &quot;%25nugetVersion%25&quot; -OutputDirectory .\artifacts" />
</Target>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,32 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="BlazorMobile">
<Version>3.0.11-preview9.19465.2</Version>
<Version>3.0.12-preview9.19465.2</Version>
</PackageReference>
<PackageReference Include="BlazorMobile.Build.Android">
<Version>3.0.11-preview9.19465.2</Version>
<Version>3.0.12-preview9.19465.2</Version>
</PackageReference>
<PackageReference Include="Xamarin.Android.Support.CustomTabs">
<Version>28.0.0.3</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" Version="3.5.0.169047" />
<PackageReference Include="Xamarin.Android.Support.Design" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Android.Support.v4" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Android.Support.v7.CardView" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Android.Support.v7.MediaRouter" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Forms">
<Version>3.5.0.169047</Version>
</PackageReference>
<PackageReference Include="Xamarin.Android.Support.Design">
<Version>28.0.0.3</Version>
</PackageReference>
<PackageReference Include="Xamarin.Android.Support.v7.AppCompat">
<Version>28.0.0.3</Version>
</PackageReference>
<PackageReference Include="Xamarin.Android.Support.v4">
<Version>28.0.0.3</Version>
</PackageReference>
<PackageReference Include="Xamarin.Android.Support.v7.CardView">
<Version>28.0.0.3</Version>
</PackageReference>
<PackageReference Include="Xamarin.Android.Support.v7.MediaRouter">
<Version>28.0.0.3</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Compile Include="MainActivity.cs" />
Expand Down
Loading

0 comments on commit bf13f6e

Please sign in to comment.