MSBUILD 排除 cs 文件
MSBUILD exclude cs files
我有一个 class 库 (TestClassLib),其中包含以下内容 classes/interfaces。
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。
是否可以排除一些不依赖于其他 classes 的 classes ?
如果你想在构建过程中排除一些class,
在 .csproj
中添加下面的注释。那么生成的dll
与B.cs
没有关系。
<ItemGroup>
<Compile Remove="B.cs" />
</ItemGroup>
我有一个 class 库 (TestClassLib),其中包含以下内容 classes/interfaces。
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。 是否可以排除一些不依赖于其他 classes 的 classes ?
如果你想在构建过程中排除一些class,
在 .csproj
中添加下面的注释。那么生成的dll
与B.cs
没有关系。
<ItemGroup>
<Compile Remove="B.cs" />
</ItemGroup>