I followed these instructions to upgrade my Xamarin.Forms project to .NETStandard 2.0. Now I added a new entry to my .resx file and get a compile error:
error CS0117: 'AppResources' does not contain a definition for 'MyKey'
I think the AppResources.Designer.cs file is not updated anymore. The following things seems to be wrong:
- According to the instructions I should delete AssemblyInfo.cs, which I have done only for the PCL and not the indivdual projects (iOS, Droid). On the other side you should add
NeutralResourcesLanguage
to the AssemblyInfo.cs according to the docs. So should I have a AssemblyInfo.cs or not? I cannot change the access modifier if I open AppResources.resx (works after manipulating .csproj)I only have this code in my new .csproj of the PCL
<ItemGroup> <EmbeddedResource Update="Common\Localization\AppResources.resx"> <Generator>ResXFileCodeGenerator </Generator> </EmbeddedResource> </ItemGroup>
- In the detailed build logs I found this and I don't know what I should do with this
1> Task "CreateCSharpManifestResourceName" skipped, due to false condition; ('%(EmbeddedResource.ManifestResourceName)' == '' and '%(EmbeddedResource.WithCulture)' == 'true' and '%(EmbeddedResource.Type)' == 'Non-Resx') was evaluated as ('' == '' and 'false' == 'true' and 'Resx' == 'Non-Resx'). 1> Task "CreateCSharpManifestResourceName" skipped, due to false condition; ('%(EmbeddedResource.ManifestResourceName)' == '' and '%(EmbeddedResource.WithCulture)' == 'true' and '%(EmbeddedResource.Type)' == 'Non-Resx') was evaluated as ('' == '' and 'true' == 'true' and 'Resx' == 'Non-Resx'). 1> Task "CreateCSharpManifestResourceName" skipped, due to false condition; ('%(EmbeddedResource.ManifestResourceName)' == '' and '%(EmbeddedResource.WithCulture)' == 'true' and '%(EmbeddedResource.Type)' == 'Non-Resx') was evaluated as ('' == '' and 'false' == 'true' and 'Non-Resx' == 'Non-Resx').
My best bet would be to manually edit the .csproj from the PCL project. In my old .csproj I had this:
<Compile Include="Common\Localization\AppResources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>AppResources.resx</DependentUpon>
</Compile>
<ItemGroup>
<EmbeddedResource Include="Common\Localization\AppResources.de.resx">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Common\Localization\AppResources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>AppResources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
But I don't think I can adopt it one-to-one. I tried to play with it, but didn't had success:
<ItemGroup>
<Compile Update="Common\Localization\AppResources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>AppResources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Common\Localization\AppResources.de.resx">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Update="Common\Localization\AppResources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>AppResources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
How do I get my translation working again?