Omit localized versions of assemblies from the build output

后端 未结 2 1457
不知归路
不知归路 2020-12-15 22:17

In one of my projects, I am using an awesome library called Humanizer. This library comes in many language variations (I counted 38).

When I build my project, I then

相关标签:
2条回答
  • What you can do is add a target (here, I named it 'RemoveSatelliteAssemblies') to the msbuild .csproj project file, for example, at the end:

    <Project...>
      ....
      <Target Name="RemoveSatelliteAssemblies" AfterTargets="ResolveAssemblyReferences">
        <ItemGroup>
            <ReferenceCopyLocalPaths Remove="@(ReferenceSatellitePaths)" />
        </ItemGroup>
      </Target>
    </Project>
    

    This target will run after the standard ResolveAssemblyReferences target (defined somewhere in a Microsoft.Common[something].targets file in the C:\Program Files (x86)\MSBuild directory or in the C:\Windows\Microsoft.Net directory - it depends on your Visual Studio / MsBuild setups and versions), and it will remove all reference satellite paths from the list of referenced paths marked as copy local (both ItemGroup names are also declared in the standard .targets file).

    0 讨论(0)
  • 2020-12-15 22:50

    With the latest msbuild you can simply put this into your .csproj file:

    <PropertyGroup>
      <SatelliteResourceLanguages>en-US</SatelliteResourceLanguages>
    </PropertyGroup>
    

    See dotnet/sdk/issues/774

    0 讨论(0)
提交回复
热议问题