我可以从构建中排除Microsoft.Data.OData语言资源吗?

Jér*_*ere 22 .net c# asp.net azure

用于c#的Azure Storage 2.0客户端使用Microsoft.Data.OData库.问题是在构建时我在我的构建文件夹中找到:

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
Run Code Online (Sandbox Code Playgroud)

等语言de,es,fr,it,ja,ko,ru,zh两次

这使得我发送到Azure云实例的软件包中的无用库大约需要3.2 Mo.我喜欢让我的包装尽可能快地发送.

我的应用程序将与Culture default和culture FR-FR一起使用

排除所有其他语言是否安全?如何在构建时实现此排除?

这是我的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>
Run Code Online (Sandbox Code Playgroud)

Han*_*ney 6

您可以做的一件事是修改您的.csproj文件,挂钩AfterBuild事件,然后删除除所需语言之外的所有文件夹.不是最佳的,但它应该工作.就像是:

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

至于是否可以安全排除......不知道.:)


Gle*_*rie 2

您可以尝试以下方法。您所说的资源是解决方案和输出的一部分,因为它们是引用的 Nuget 包的一部分。具体是这些:

  • 微软数据.OData 5.2.0
  • 微软.Data.Edm 5.2.0
  • 系统空间5.2.0

我不确定这些版本与本主题的相关程度如何,但我创建了一个新的 ASP.NET MVC 4.5 Web 应用程序并添加了 Windows Azure Storage 2.0 包,最终安装了它们。

现在,有一个名为 Nuget Package Explorer 的开源工具:http://npe.codeplex.com/

使用 NPE,您可以打开、查看和编辑 Nuget 包。packages您将在与解决方案所在的相同相对路径的目录 中找到包含这些包的文件夹。

您需要使用 NPE 编辑包并删除对资源文件的引用并保存包。您还需要从packages文件夹中删除实际的资源程序集。

您应该能够执行Clean Solution...andRebuild Solution并查看软件在没有这些引用的情况下进行编译。

该技术本质上是调整依赖项的配置以影响构建输出。