Visual Studio 的csproj项目文件简释
文档结构
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- TargetFramework:目标框架(当前项目的.Net框架) -->
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<!-- Import:引用文件 -->
<Import Project="Props文件1.props" />
<!-- PropertyGroup:项目的属性组(我的理解),合并为一节点或分开多节点效果一样 -->
<PropertyGroup>
<Product>产品名称</Product>
<Description>产品说明</Description>
<Authors>作者</Authors>
<Company>公司</Company>
<Copyright>版权</Copyright>
</PropertyGroup>
<PropertyGroup>
<Version>版本号</Version>
<AssemblyVersion>程序集版本号</AssemblyVersion>
<FileVersion>文件版本号</FileVersion>
</PropertyGroup>
<PropertyGroup>
<!-- CopyLocalLockFileAssemblies:生成是否包括引用项(DLL、Nuget包) -->
<CopyLocalLockFileAssemblies>false</CopyLocalLockFileAssemblies>
</PropertyGroup>
<!-- Debug时的输出路径 -->
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<OutputPath>..\..\..\Output\</OutputPath>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
<DocumentationFile>$(OutputPath)\$(Product).xml</DocumentationFile>
</PropertyGroup>
<!-- Release时的输出路径 -->
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<OutputPath>..\..\..\Release\</OutputPath>
<DebugType>none</DebugType>
<DebugSymbols>false</DebugSymbols>
</PropertyGroup>
<!-- ItemGroup:项目的内容组(我的理解),包括文件与引用,合并为一节点或分开多节点效果一样 -->
<ItemGroup>
<!-- PackageReference:Nuget包引用项 -->
<PackageReference Include="Autofac" Version="6.0.0" />
</ItemGroup>
<ItemGroup>
<!-- PackageReference:项目引用项 -->
<ProjectReference Include="..\ONS.Data\ONS.Data.csproj" />
</ItemGroup>
</Project>
分布式csproj项目文件
props文件
1.props文件,即以后缀名.props结尾的文件,如:project.props;
2.props文件与csproj文件结构语法一致;
3.csproj文件可以通过props文件进行全局性的项目属性分布(如统一版本号、统一输出等);
引用props文件
1.csproj文件引用props文件,以及props文件引用props文件,是通过Import进行引用,如下所示:
<Import Project="Props文件1.props" />