Add resx file to C# project file

Posts   
 
    
basik
User
Posts: 123
Joined: 20-Aug-2012
# Posted on: 19-Feb-2014 10:49:57   

Hi,

I'm using a custom template to add a resource file to a csproj. The resource files are simply literal lpt templates - what is in the lpt is the file content. So when I run the CodeGen I get 2 files output: Resources\Messages.Designer.cs Resource\Messages.resx

The issue I have it that the Compile entry in the csproj file does not produce the necessary Xml as shown below:

Required csproj entry


<ItemGroup>
<Compile Include="Resources\Messages.Designer.cs">
      <DependentUpon>Messages.resx</DependentUpon>
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
</Compile>
</ItemGroup>
<ItemGroup>
    <EmbeddedResource Include="Resources\Messages.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>Messages.Designer.cs</LastGenOutput>
    </EmbeddedResource>
  </ItemGroup>

Actual result in csproj file


 <ItemGroup>
   <Compile Include="Resources\Messages.resx">
      <GeneratedBy>LLBLGen Pro</GeneratedBy>
    </Compile>
 <Compile Include="Resources\Messages.resx">
      <GeneratedBy>LLBLGen Pro</GeneratedBy>
    </Compile>
  </ItemGroup>
  <ItemGroup>
    <EmbeddedResource Include="Resources\Messages.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>Messages.Designer.cs</LastGenOutput>
    </EmbeddedResource>
  </ItemGroup>

How do you ensure the correct csproj file entry by excluding the <Compile Include="Resources\Messages.resx"> entry ? Thank you. Using LLBLGENPRO 3.5 Final version.

basik
User
Posts: 123
Joined: 20-Aug-2012
# Posted on: 19-Feb-2014 12:11:30   

I have tried changing the buildActionPerExtension on the project file template settings: .resx;EmbeddedResource|.config;None|;Compile which produces the following entry. That prevents the Compile Include for the .resx file but doesn't result in the expected output.


<ItemGroup>
   <Compile Include="Resources\Messages.Designer.cs">
      <GeneratedBy>LLBLGen Pro</GeneratedBy>
    </Compile>
    <EmbeddedResource Include="Resources\Messages.resx">
      <GeneratedBy>LLBLGen Pro</GeneratedBy>
    </EmbeddedResource>
</ItemGroup>

This does not work as the DependentUpon entry is missing. It should look like this:


<ItemGroup>
<Compile Include="Resources\Messages.Designer.cs">
     <DependentUpon>Messages.resx</DependentUpon>
     <AutoGen>True</AutoGen>
     <DesignTime>True</DesignTime>
</Compile>
<EmbeddedResource Include="Resources\Messages.resx">
      <GeneratedBy>LLBLGen Pro</GeneratedBy>
</EmbeddedResource>
</ItemGroup>

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39760
Joined: 17-Aug-2003
# Posted on: 19-Feb-2014 13:27:45   

DependentUpon is currently being developed (today even simple_smile ) for v4.2. So it's currently not possible to generate that element into the project file, unfortunately. Use a vs.net extension to group files together in solution explorer like nestln http://visualstudiogallery.msdn.microsoft.com/9d6ef0ce-2bef-4a82-9a84-7718caa5bb45

Frans Bouma | Lead developer LLBLGen Pro
basik
User
Posts: 123
Joined: 20-Aug-2012
# Posted on: 19-Feb-2014 17:52:02   

Otis wrote:

DependentUpon is currently being developed (today even simple_smile ) for v4.2. So it's currently not possible to generate that element into the project file, unfortunately. Use a vs.net extension to group files together in solution explorer like nestln http://visualstudiogallery.msdn.microsoft.com/9d6ef0ce-2bef-4a82-9a84-7718caa5bb45

Thank you for the quick response. The pragmatic fix here is just to add those entries to project file lpt template and then just clean up post generation. Nestln looks like it will be just the thing to use.

basik
User
Posts: 123
Joined: 20-Aug-2012
# Posted on: 23-Jul-2014 11:53:31   

Just wondering if this is now supported in v4.2

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39760
Joined: 17-Aug-2003
# Posted on: 23-Jul-2014 13:39:47   

Yes.

The details are in the upcoming SDK. Quoted below is the details from the design doc:

The code generators have now support for emiting DependentUpon elements. This is done through a new optional parameter on code generator task performers called dependentUponFileFormat, which uses the same filename characteristics as the filenameFormat parameter. The same logic is used to create a full filename.

There's a new task cache element added, called dependentUponFiles which has per entry as key the file which should get the dependentUpon element in the project file and as value the filename it is dependent upon.

Every task which has the parameter DependentUpon specified with a non-empty value gets its file added to this cache.

The ProjectFileCreator task performer will use the new cache element to emit DependentUpon xml elements in the project file.

So specify the parameter at the task level with a value using the same fileformat characteristics so you can specify to which file the file to emit is depending upon. It is then added to a cache which will take care of the emit of the xml elements (so you don't have to do anything for that).

Frans Bouma | Lead developer LLBLGen Pro
basik
User
Posts: 123
Joined: 20-Aug-2012
# Posted on: 23-Jul-2014 16:30:28   

Excellent. I actually ended up with a custom version of the ProjectFileCreator in our TaskPerformer which does just that. But I much prefer using the out the box options and only customise what is really needed.

I'm a big fan of the wheel!

Thank you.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39760
Joined: 17-Aug-2003
# Posted on: 23-Jul-2014 17:23:30   

smile

Frans Bouma | Lead developer LLBLGen Pro