问题描述
假设我有一个解决方案中使用的 .vsprops
文件。在该文件中,定义了各种变量,例如中间生成结果的 int_dir
和日志结果的 log_dir
。 通常情况下,这些变量被设置为默认值(相对于解决方案)。
对我来说,我会比如将这两个变量设置为我的虚拟硬盘( R:
),即不再是
$(SolutionDir)\intermediate
但是
R:\ myproject \intermediate
.vsprops 文件,源代码管理(Git)会将它标记为已修改。
有没有在VSPROPS中的方法,以便我可以检查一个环境变量,如果这个变量没有设置,使用默认值?
如果这是不可能的,我也会对Git的解决方案感兴趣,以解决这个问题(但不是 - assume-unchanged
而不是 .gitignore $ c $因为mayb这个文件中的其他变化可能是相关的)。
纯粹的Git解决方案可以使用:
在 git checkout
上执行的 smudge
脚本,它将会:
$(SolutionDir)
(例如,测试其中包含更新路径的环境变量)
xxx.vsprops.tpl
)内容(脚本不知道文件名或路径, / li>
.vsprops
从 .vsprops.tpl
(模板文件),这是正在版本化的版本( .vsprops
)不再是版本)
您可以添加一个干净的
脚本, code> git commit )在 .vsprops
文件中完成的所有修改回到 .vsprops.tpl
, $(SolutionDir)
行除外。
Say I've got a .vsprops
file that is used in a solution. In that file, various variables are defined such as int_dir
for intermediate build results and log_dir
for the log results.
Usually, these variables get set to default values (relative to the solution).
For me, I'd like to set these two variables to my ramdisk (R:
), i.e. no longer
$(SolutionDir)\intermediate
but
R:\myproject\intermediate
If I change the .vsprops
file directly, the source control (Git) will mark it as modified.
Is there a way in VSPROPS so that I could check maybe an environment variable and if this variable is not set, the default is used?
If this is not possible, I'd also be interested in a solution for Git to overcome this (but not --assume-unchanged
and not .gitignore
because maybe other changes in that file could be relevant).
A pure Git solution could use a gitattribute filter driver:
It would involve a smudge
script, executed on git checkout
, which would:
- detect if you want to change
$(SolutionDir)
(for instance, test for an environment variable with the updated path in it) - detect the right file (
xxx.vsprops.tpl
) content (the script doesn't know the file names or path it operates on) - generate the actual
.vsprops
from a.vsprops.tpl
(template file) which is the one being versioned (the.vsprops
is no longer versioned)
You can add a clean
script which would preserve (on git commit
) all the modification done in the .vsprops
file back to the .vsprops.tpl
, except for the $(SolutionDir)
line.
这篇关于只有在VSPROPS变量尚不存在的情况下如何设置VSPROPS变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!