c# - MSBUILD 排除 cs 文件
问题描述
我有一个带有以下类/接口的类库(TestClassLib)。
IA.cs
A.cs(实现 IA)
IB.cs
B.cs(实现 IB)
A 和 B 没有依赖关系。
在 TestClasslib.csproj 中,我有以下 XML
<PropertyGroup>
<Builtdir>built</Builtdir>
<AssemblyName>Dabba</AssemblyName>
<OutputPath>Bin\</OutputPath>
<Configurations>Debug;Release;Test</Configurations>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<CSFile Include="*.cs;" Exclude="B.cs" />
</ItemGroup>
<Target Name="Compile">
<Csc Sources="@(CSFile)" OutputAssembly="$(AssemblyName).dll" TargetType="dll" />
</Target>
</Project>
只想在创建 dll 时排除 B.cs。是否可以排除少数不依赖其他类的类?
解决方案
如果要在构建过程中排除某些类,请在.csproj
. 那么生成dll
的就没有关系了B.cs
。
<ItemGroup>
<Compile Remove="B.cs" />
</ItemGroup>
推荐阅读
- android - 而谷歌的短信一次性代码自动填充服务,API_NOT_AVAILABLE 状态是什么意思?
- java - Apache POI:一个单元格中不允许有多个单元格注释
- avfoundation - iOS - 如何检查相机胶卷中的类似视频?
- hadoop - `hive.exec.max.dynamic.partitions` 和 `hive.exec.max.dynamic.partitions.pernode` 的区别
- java - 如何使用片段调用另一个xml列表视图下的android:onClick on xml按钮?
- python - pandas 将跨多列的值计数汇总到摘要数据框中
- html - 对齐 Angular ICON 和 HTML 文本
- sticky - 不使用高度参数的制表符粘性标题
- oracle - 在 Oracle SQL 中创建表时如何定义时间数据类型
- php - PHP gd库displsys黑屏带白框而不是图像