Skip to content

Commit

Permalink
[msbuild] Warn when we detect that the app developer is trying to lin…
Browse files Browse the repository at this point in the history
…k with a static library when using Hot Restart. Fixes #17640. (#18940)

Warn when we detect that the app developer is trying to link with a static
library when using Hot Restart, because we don't support linking with static
libraries in that case.

Also change the resource generation for Xamarin.iOS.Tasks.Windows project to
generate the code-behind for the resources during the build (as opposed to by
the IDE - which won't happen unless using an IDE, while the build will always
happen).

Fixes #17640.
  • Loading branch information
rolfbjarne authored Sep 7, 2023
1 parent 1c8c4fb commit 08ad43a
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 21 deletions.
55 changes: 40 additions & 15 deletions msbuild/Xamarin.iOS.Tasks.Windows/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions msbuild/Xamarin.iOS.Tasks.Windows/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@
<value>Info.plist file does not exist under {0}, please rebuild your project</value>
<comment>0: path</comment>
</data>
<data name="HotRestartStaticLibraryNotSupported" xml:space="preserve">
<value>Linking with a static library is not supported when using Hot Restart.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;

using Xamarin.iOS.Tasks.Windows.Properties;
using Xamarin.MacDev.Tasks;

#nullable enable
Expand Down Expand Up @@ -139,11 +140,13 @@ public override bool Execute ()
case PublishFolderType.Unknown: // Don't copy unknown stuff anywhere
case PublishFolderType.AppleBindingResourcePackage: // These aren't copied to the bundle
case PublishFolderType.CompressedAppleBindingResourcePackage: // These aren't copied to the bundle
case PublishFolderType.StaticLibrary: // These aren't copied to the bundle
case PublishFolderType.CompressedAppleFramework: // Shouldn't really happen? Should be uncompresed by the time we get here.
case PublishFolderType.CompressedPlugIns: // Shouldn't really happen? Should be uncompresed by the time we get here.
Log.LogMessage (MessageImportance.Low, $" Skipped {item.ItemSpec} because PublishFolderType={publishFolderType} items aren't copied to the app bundle.");
continue;
case PublishFolderType.StaticLibrary: // These aren't copied to the bundle
Log.LogWarning (null, null, null, item.ItemSpec, 0, 0, 0, 0, Resources.HotRestartStaticLibraryNotSupported);
continue;
default:
Log.LogMessage (MessageImportance.Low, $" Skipped {item.ItemSpec} because of unknown PublishFolderType={publishFolderType}.");
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,18 @@
<Folder Include="Tasks\" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Properties\Resources.Designer.cs" />
<EmbeddedResource Update="Properties\Resources.resx">
<Type>Resx</Type>
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<StronglyTypedFileName>Properties/Resources.Designer.cs</StronglyTypedFileName>
<StronglyTypedLanguage>CSharp</StronglyTypedLanguage>
<StronglyTypedNamespace>Xamarin.iOS.Tasks.Windows.Properties</StronglyTypedNamespace>
<StronglyTypedClassName>Resources</StronglyTypedClassName>
<GenerateResource>true</GenerateResource>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>

<Import Project="$(MSBuildThisFileDirectory)..\ILMerge.targets" />

Expand Down

5 comments on commit 08ad43a

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

Please sign in to comment.