-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Fix NativeAOT publish including satellite assemblies despite embedding them #124192
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e1bca05
Initial plan
Copilot 1801e3b
Add fix to remove satellite assemblies from publish folder and create…
Copilot 3feb4a7
Remove test from runtime repo per review feedback
Copilot 875ec0e
Merge remote-tracking branch 'origin/main' into satellite
sbomer 58612b9
Merge remote-tracking branch 'origin/main' into satellite
sbomer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
src/tests/nativeaot/SmokeTests/SatelliteAssemblies/Program.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System; | ||
| using System.Globalization; | ||
| using System.IO; | ||
| using System.Reflection; | ||
| using System.Resources; | ||
|
|
||
| class Program | ||
| { | ||
| static int Main(string[] args) | ||
| { | ||
| // Test that we can access resources | ||
| ResourceManager rm = new ResourceManager("SatelliteAssemblies.Strings", Assembly.GetExecutingAssembly()); | ||
|
|
||
| // Test English (default) | ||
| string englishGreeting = rm.GetString("Greeting", CultureInfo.InvariantCulture); | ||
| Console.WriteLine($"English: {englishGreeting}"); | ||
| if (englishGreeting != "Hello, World!") | ||
| { | ||
| Console.WriteLine("ERROR: Expected 'Hello, World!' for English"); | ||
| return 1; | ||
| } | ||
|
|
||
| // Test Spanish | ||
| string spanishGreeting = rm.GetString("Greeting", new CultureInfo("es")); | ||
| Console.WriteLine($"Spanish: {spanishGreeting}"); | ||
| if (spanishGreeting != "¡Hola, Mundo!") | ||
| { | ||
| Console.WriteLine("ERROR: Expected '¡Hola, Mundo!' for Spanish"); | ||
| return 1; | ||
| } | ||
|
|
||
| // Verify that satellite assemblies are NOT in the publish directory | ||
| // when this is published with PublishAot | ||
| string exePath = Environment.ProcessPath ?? Assembly.GetExecutingAssembly().Location; | ||
| string publishDir = Path.GetDirectoryName(exePath); | ||
|
|
||
| if (string.IsNullOrEmpty(publishDir)) | ||
| { | ||
| Console.WriteLine("ERROR: Could not determine publish directory"); | ||
| return 1; | ||
| } | ||
|
|
||
|
sbomer marked this conversation as resolved.
Outdated
|
||
| // Check that the 'es' subdirectory does not exist in publish output | ||
| string esDir = Path.Combine(publishDir, "es"); | ||
| if (Directory.Exists(esDir)) | ||
| { | ||
| Console.WriteLine($"ERROR: Satellite assembly directory exists: {esDir}"); | ||
| Console.WriteLine("Satellite assemblies should be embedded in the native binary, not copied to publish folder"); | ||
|
|
||
| // List what's in there for diagnostic purposes | ||
| var files = Directory.GetFiles(esDir); | ||
| foreach (var file in files) | ||
| { | ||
| Console.WriteLine($" Found: {Path.GetFileName(file)}"); | ||
| } | ||
|
|
||
| return 1; | ||
| } | ||
|
|
||
| Console.WriteLine("SUCCESS: Resources are accessible and no satellite assembly folders in publish directory"); | ||
| return 100; | ||
| } | ||
| } | ||
13 changes: 13 additions & 0 deletions
13
src/tests/nativeaot/SmokeTests/SatelliteAssemblies/SatelliteAssemblies.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <CLRTestPriority>0</CLRTestPriority> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <EmbeddedResource Include="Strings.resx" /> | ||
| <EmbeddedResource Include="Strings.es.resx" /> | ||
| <Compile Include="Strings.Designer.cs" /> | ||
| <Compile Include="Program.cs" /> | ||
| </ItemGroup> | ||
| </Project> |
28 changes: 28 additions & 0 deletions
28
src/tests/nativeaot/SmokeTests/SatelliteAssemblies/Strings.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
64 changes: 64 additions & 0 deletions
64
src/tests/nativeaot/SmokeTests/SatelliteAssemblies/Strings.es.resx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <root> | ||
| <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> | ||
| <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> | ||
| <xsd:element name="root" msdata:IsDataSet="true"> | ||
| <xsd:complexType> | ||
| <xsd:choice maxOccurs="unbounded"> | ||
| <xsd:element name="metadata"> | ||
| <xsd:complexType> | ||
| <xsd:sequence> | ||
| <xsd:element name="value" type="xsd:string" minOccurs="0" /> | ||
| </xsd:sequence> | ||
| <xsd:attribute name="name" use="required" type="xsd:string" /> | ||
| <xsd:attribute name="type" type="xsd:string" /> | ||
| <xsd:attribute name="mimetype" type="xsd:string" /> | ||
| <xsd:attribute ref="xml:space" /> | ||
| </xsd:complexType> | ||
| </xsd:element> | ||
| <xsd:element name="assembly"> | ||
| <xsd:complexType> | ||
| <xsd:attribute name="alias" type="xsd:string" /> | ||
| <xsd:attribute name="name" type="xsd:string" /> | ||
| </xsd:complexType> | ||
| </xsd:element> | ||
| <xsd:element name="data"> | ||
| <xsd:complexType> | ||
| <xsd:sequence> | ||
| <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | ||
| <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> | ||
| </xsd:sequence> | ||
| <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> | ||
| <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> | ||
| <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> | ||
| <xsd:attribute ref="xml:space" /> | ||
| </xsd:complexType> | ||
| </xsd:element> | ||
| <xsd:element name="resheader"> | ||
| <xsd:complexType> | ||
| <xsd:sequence> | ||
| <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | ||
| </xsd:sequence> | ||
| <xsd:attribute name="name" type="xsd:string" use="required" /> | ||
| </xsd:complexType> | ||
| </xsd:element> | ||
| </xsd:choice> | ||
| </xsd:complexType> | ||
| </xsd:element> | ||
| </xsd:schema> | ||
| <resheader name="resmimetype"> | ||
| <value>text/microsoft-resx</value> | ||
| </resheader> | ||
| <resheader name="version"> | ||
| <value>2.0</value> | ||
| </resheader> | ||
| <resheader name="reader"> | ||
| <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | ||
| </resheader> | ||
| <resheader name="writer"> | ||
| <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | ||
| </resheader> | ||
| <data name="Greeting" xml:space="preserve"> | ||
| <value>¡Hola, Mundo!</value> | ||
| </data> | ||
| </root> |
64 changes: 64 additions & 0 deletions
64
src/tests/nativeaot/SmokeTests/SatelliteAssemblies/Strings.resx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <root> | ||
| <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> | ||
| <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> | ||
| <xsd:element name="root" msdata:IsDataSet="true"> | ||
| <xsd:complexType> | ||
| <xsd:choice maxOccurs="unbounded"> | ||
| <xsd:element name="metadata"> | ||
| <xsd:complexType> | ||
| <xsd:sequence> | ||
| <xsd:element name="value" type="xsd:string" minOccurs="0" /> | ||
| </xsd:sequence> | ||
| <xsd:attribute name="name" use="required" type="xsd:string" /> | ||
| <xsd:attribute name="type" type="xsd:string" /> | ||
| <xsd:attribute name="mimetype" type="xsd:string" /> | ||
| <xsd:attribute ref="xml:space" /> | ||
| </xsd:complexType> | ||
| </xsd:element> | ||
| <xsd:element name="assembly"> | ||
| <xsd:complexType> | ||
| <xsd:attribute name="alias" type="xsd:string" /> | ||
| <xsd:attribute name="name" type="xsd:string" /> | ||
| </xsd:complexType> | ||
| </xsd:element> | ||
| <xsd:element name="data"> | ||
| <xsd:complexType> | ||
| <xsd:sequence> | ||
| <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | ||
| <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> | ||
| </xsd:sequence> | ||
| <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> | ||
| <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> | ||
| <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> | ||
| <xsd:attribute ref="xml:space" /> | ||
| </xsd:complexType> | ||
| </xsd:element> | ||
| <xsd:element name="resheader"> | ||
| <xsd:complexType> | ||
| <xsd:sequence> | ||
| <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | ||
| </xsd:sequence> | ||
| <xsd:attribute name="name" type="xsd:string" use="required" /> | ||
| </xsd:complexType> | ||
| </xsd:element> | ||
| </xsd:choice> | ||
| </xsd:complexType> | ||
| </xsd:element> | ||
| </xsd:schema> | ||
| <resheader name="resmimetype"> | ||
| <value>text/microsoft-resx</value> | ||
| </resheader> | ||
| <resheader name="version"> | ||
| <value>2.0</value> | ||
| </resheader> | ||
| <resheader name="reader"> | ||
| <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | ||
| </resheader> | ||
| <resheader name="writer"> | ||
| <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | ||
| </resheader> | ||
| <data name="Greeting" xml:space="preserve"> | ||
| <value>Hello, World!</value> | ||
| </data> | ||
| </root> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.