以下属性是基本的输出路径属性,可以在 Microsoft.NET.DefaultOutputPaths.targets 找到。
$(Configuration)
$(Platform)
AnyCPU
,还可以是 x86
、x64
或者 ARM
。$(BaseOutputPath)
bin\
。修改这个属性可以间接修改 OutputPath
。$(OutputPath)
AnyCPU
编译,就是 $(BaseOutputPath)$(Configuration)\
;否则就是 $(BaseOutputPath)$(PlatformName)\$(Configuration)\
$(BaseIntermediateOutputPath)
obj\
。修改这个属性可以间接修改 IntermediateOutputPath
。$(IntermediateOutputPath)
AnyCPU
编译,就是 $(BaseIntermediateOutputPath)$(Configuration)\
;否则就是 $(BaseIntermediateOutputPath)$(PlatformName)\$(Configuration)\
写在 csproj 文件中 ItemGroup 组中的每一个元素即“项”。
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<NeutralLanguage>zh-Hans</NeutralLanguage>
<RootNamespace>FirstSolver</RootNamespace>
<Authors>秦建辉</Authors>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<AssemblyVersion>1.0.0</AssemblyVersion>
<FileVersion>$(AssemblyVersion)</FileVersion>
<Version>$(AssemblyVersion)</Version>
<Title>$(AssemblyName)</Title>
<Description>$(Title)</Description>
<PackageId>$(AssemblyName)</PackageId>
<PackageIcon>FirstSolver.png</PackageIcon>
<PackageTags>$(AssemblyName)</PackageTags>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'== 'Debug'">
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<ItemGroup>
<None Include="..\$(PackageIcon)" Link="$(PackageIcon)">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="C2VCommon" Version="1.8.4" />
</ItemGroup>
<ItemGroup>
<None Include="..\GoogolSdk\*.dll" Link="%(Filename)%(Extension)">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Pack>True</Pack>
<PackagePath>runtimes\win-x64\native</PackagePath>
</None>
<None Include="..\GoogolSdk\GlinkCfg.txt" Link="GlinkCfg.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Pack>True</Pack>
<PackagePath>contentFiles\any\any</PackagePath>
</None>
<None Include="build\*.props">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
<Pack>True</Pack>
<PackagePath>build</PackagePath>
</None>
</ItemGroup>
<ItemGroup>
<Compile Include="..\GoogolSdk\*.cs" Link="%(Filename)%(Extension)" />
</ItemGroup>
</Project>
那么,可用的属性有:
%(FullPath)
E:\MachiningService\GoogolSdk\gts.cs
%(RootDir)
E:\
%(Filename)
gts
%(Extension)
.cs
%(RelativeDir)
GoogolSdk\
%(Directory)
MachiningService\GoogolSdk
%(RecursiveDir)
MachiningService\GoogolSdk\
%(Identity)
..\GoogolSdk\*.cs
%(ModifiedTime)
2025-04-12 21:00:43.7851385
%(CreatedTime)
2025-04-12 21:01:50.1417635
%(AccessedTime)
2025-04-12 21:02:15.4132476
$(MSBuildProjectFullPath)
E:\MachiningService\MachiningService\MachiningService.csproj
$(MSBuildProjectDirectory)
E:\MachiningService\MachiningService
$(MSBuildProjectFile)
MachiningService.csproj
$(MSBuildProjectName)
MachiningService
$(MSBuildProjectExtension)
.csproj
$(MSBuildProjectDirectoryNoRoot)
$(MSBuildThisFileFullPath)
E:\MachiningService\MachiningService\build\MachiningService.props
$(MSBuildThisFileDirectory)
E:\MachiningService\MachiningService\build\
$(MSBuildThisFile)
MachiningService.props
$(MSBuildThisFileName)
MachiningService
$(MSBuildThisFileExtension)
.props
$(MSBuildThisFileDirectoryNoRoot)
$(MSBuildStartupDirectory)
$(MSBuildToolsPath)
$(MSBuildToolsVersion)
另外还有一些在新的 SDK 中几乎不会在日常开发中用到的全局属性:
$(MSBuildBinPath)
: MSBuild 程序所在的路径$(MSBuildExtensionsPath)
: 自定义 targets 所在的路径$(MSBuildExtensionsPath32)
: 自定义 targets 所在的路径$(MSBuildExtensionsPath64)
: 自定义 targets 所在的路径原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。