在我的csproj文件中,我有一个不同的构建路径。
<BaseIntermediateOutputPath>C:\Temp\Build\MyProject</BaseIntermediateOutputPath>
在prebuild和post build事件中,我可以访问某些宏变量。
$(OutDir)
$(ProjectName)
$(ProjectPath)
$(SolutionDir)
我可以在csproj中使用这些变量吗?
例如,我尝试了以下内容但没有成功。
<BaseIntermediateOutputPath>C:\Temp\Build\$(ProjectName)</BaseIntermediateOutputPath>
答案 0 :(得分: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的一部分,但我相信这对于那些对他们的obj文件使用RAMDISK有类似要求并且发现在vbproj / csproj文件中更改驱动器号的情况很麻烦的其他人会很方便。