Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I exclude Microsoft.Data.OData languages ressources from build?

Azure Storage 2.0 client for c# use Microsoft.Data.OData library. The problem is that at build i find in my build folder :

bin/de/Microsoft.Data.Edm.resources.dll
bin/de/Microsoft.Data.OData.resources.dll
bin/de/Microsoft.Data.Services.Client.resources.dll
bin/de/System.Spatial.resources.dll
bin/es/Microsoft.Data.Edm.resources.dll
bin/es/Microsoft.Data.OData.resources.dll
bin/es/Microsoft.Data.Services.Client.resources.dll
bin/es/System.Spatial.resources.dll

etc for languages de, es, fr, it, ja, ko, ru, zh twice

That makes around 3.2 Mo of I guess useless library in the package I send to Azure Cloud Instance. I like to have my packages the lightest possible to be sent quickly.

My application is set to work with Culture default and culture FR-FR

Is it safe to exclude all other language and HOW can I achieve this exclusion on build ?

Here is my webconfig

<runtime>
     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
           <assemblyIdentity name="Microsoft.WindowsAzure.Storage" publicKeyToken="31bf3856ad364e35" culture="neutral" />
           <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
        </dependentAssembly>
        <dependentAssembly>
           <assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral" />
           <bindingRedirect oldVersion="0.0.0.0-5.6.1.0" newVersion="5.6.1.0" />
        </dependentAssembly>
        <dependentAssembly>
           <assemblyIdentity name="Microsoft.Data.Services.Client" publicKeyToken="31bf3856ad364e35" culture="neutral" />
           <bindingRedirect oldVersion="0.0.0.0-5.6.1.0" newVersion="5.6.1.0" />
        </dependentAssembly>
        <dependentAssembly>
           <assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral" />
           <bindingRedirect oldVersion="0.0.0.0-5.6.1.0" newVersion="5.6.1.0" />
        </dependentAssembly>
     </assemblyBinding>
  </runtime>
like image 596
Jérôme Tarere Avatar asked Nov 19 '14 20:11

Jérôme Tarere


2 Answers

One thing you could do is modify your .csproj file, hook into the AfterBuild event, and then delete the folders for all but the desired language. Not optimal, but it should work. Something like:

<Target Name="AfterBuild">
  <ItemGroup>
    <DirsToClean Include="$(OutDir)\de;$(OutDir)\es;..." />
  </ItemGroup>
  <RemoveDir Directories="@(DirsToClean)" />
</Target>

As for whether it's safe to exclude... no idea. :)

like image 99
Haney Avatar answered Nov 09 '22 03:11

Haney


Here is a approach that you can try. The resources you are speaking of are a part of the solution and output because they are a part of referenced Nuget packages. Specifically these:

  • Microsoft.Data.OData 5.2.0
  • Microsoft.Data.Edm 5.2.0
  • System.Spatial 5.2.0

I'm not certain how relevant the versions are to this topic, but I created a new ASP.NET MVC 4.5 Web application and added Windows Azure Storage 2.0 package and they were installed as a result.

Now, there is an open source tool called Nuget Package Explorer: http://npe.codeplex.com/

With NPE, you can open, view, and edit Nuget packages. You will find the folder containing these packages in the packages directory in the same relative path to where your solution is.

You need to edit the package with NPE and remove the references to the resource files there and save the package. You will also need to delete the actual resource assemblies from the packages folder.

You should be able to perform a Clean Solution... and Rebuild Solution and see the software compile without those references.

This technique is essentially adjusting the configuration of your dependencies to affect the build output.

like image 20
Glenn Ferrie Avatar answered Nov 09 '22 02:11

Glenn Ferrie