如何添加水珠为新SDK的csproj文件
问题描述:
RESX文件,如果我从VS2017添加一个新的resx文件到我的属性文件夹在我的新dotnetstandard 2.0 SDK的项目,我看到如何添加水珠为新SDK的csproj文件
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Remove="Properties\foo.resx" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\MyWords.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>MyWords.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\MyWords.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>MyWords.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>
但是我宁愿以这种方式处理正常的cs文件的处理方式。该项目为空,并搜索文件系统。什么是globby的方式来实现上述,所以当我添加新文件时,他们并没有最终明确声明。
我第一次尝试是
<ItemGroup>
<Compile Update="Properties\**\*.designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Properties\%(Filename).resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\**\*.resx">
<Generator>ResXFileCodeGenerator</Generator>
</EmbeddedResource>
</ItemGroup>
但是这不会起作用,因为
Properties\%(Filename).resx
扩展到
Properties\Foo.designer.resx
,而不是
Properties\Foo.resx
答
您可以在元数据使用属性功能,以便与擦除与string.replace的.Designer
部分应确定:
<Compile Update="Properties\**\*.designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Properties\$([System.String]::Copy('%(FileName)').Replace('.Designer', '')).resx</DependentUpon>
</Compile>