6

在我的 csproj 文件中,我有不同的构建路径。

<BaseIntermediateOutputPath>C:\Temp\Build\MyProject</BaseIntermediateOutputPath>

在预构建和构建后事件中,我可以访问某些宏变量。

$(OutDir)
$(ProjectName)
$(ProjectPath)
$(SolutionDir)

我可以在我的 csproj 中使用这些变量吗?

例如,我尝试了以下但没有成功。

<BaseIntermediateOutputPath>C:\Temp\Build\$(ProjectName)</BaseIntermediateOutputPath>
4

1 回答 1

5

我有类似的要求,使用 $(MSBuildProjectName) 为我完成了这项工作。

  <PropertyGroup>
    <ProjectView>ProjectFiles</ProjectView>
    <BaseIntermediateOutputPath>R:\$(MSBuildProjectName)\obj\</BaseIntermediateOutputPath>
  </PropertyGroup>

这里 R: 是我的 RAMDISK 驱动器号。

对于其他可能在正确设置 RAMDISK 驱动器号时遇到问题的人,我使用了一个简单的 VBS 脚本

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colVolumes = objWMIService.ExecQuery _
    ("Select * from Win32_Volume") Where Label = 'RAMDISK'")
For Each objVolume in colVolumes
    objVolume.DriveLetter = "R:"
    objVolume.Put_
Next

这可确保加载带有标签 RAMDISK 的任何驱动器都设置为 R: 驱动器,而不是出现的默认驱动器。虽然这不是您 Q 的一部分,但我相信这对于其他有类似要求的其他人来说会很方便,他们需要将 RAMDISK 用于他们的 obj 文件,并且发现在 vbproj/csproj 文件中更改驱动器号的情况很麻烦。

参考:

  1. 保留属性:http: //msdn.microsoft.com/en-us/library/ms164309%28loband%29.aspx
  2. 更改驱动器号:http ://www.activexperts.com/activmonitor/windowsmanagement/adminscripts/disk/drives/
于 2012-02-26T07:34:08.893 回答