简体   繁体   English

Visual Studio发布MSdeploy $(SolutionDir)

[英]Visual Studio Publish MSdeploy $(SolutionDir)

I'm having an annoying issue with MSDeploy and Visual Studio's publish profile. 我在使用MSDeploy和Visual Studio的发布配置文件时遇到麻烦的问题。 In my project I have a property group that I setup an item to reference later. 在我的项目中,我有一个属性组,我设置了一个项目供以后参考。

<LocalBuildLocation>$(SolutionDir)WebSites\MyWebSite\</LocalBuildLocation>

Unfortunately, Visual Studio will randomly drop the $(SolutionDir) string from this property and my build will fail. 不幸的是,Visual Studio将从该属性中随机删除$(SolutionDir)字符串,并且我的构建将失败。 I copy it back in manually and everything is good to go. 我将其手动复制回去,一切顺利。

Can anyone think of why this item keeps removing itself? 谁能想到这个项目为何会不断将其移除?

From MSDN: Using project properties in assembly and include directives MSDN:在程序集中使用项目属性并包含指令

Visual Studio macros like $(SolutionDir) don't work in MSBuild. $(SolutionDir)这样的Visual Studio宏在MSBuild中不起作用。 You can use project properties instead. 您可以改用项目属性。

Use $(ProjectDir) (safer, project level property) or $(MSBuildProjectDirectory) (safest, always exist) 使用$(ProjectDir) (更安全的项目级别属性)或$(MSBuildProjectDirectory) (最安全,始终存在)

See: $(SolutionDir) MSBuild property incorrect when running Sandcastle Help File Builder via CMD and getting the value of $(ProjectDir), $(SolutionDir) in a vcproj file 请参阅: $(SolutionDir)MSBuild属性不正确,当通过CMD运行Sandcastle帮助文件生成器在vcproj文件中获取$(ProjectDir),$(SolutionDir)的值时

It looks like $SolutionDir does (sometimes) work with MSBuild, but only if you're building from the solution file. 看起来$SolutionDir (有时)可以与MSBuild一起使用,但是仅当您从解决方案文件进行构建时。 It is the same thing as $ProjectDir for the most part. 大多数情况下,它与$ProjectDir相同。

But you're not supposed to be able to use them in MSBuild. 但是,您不应在MSBuild中使用它们。 Even though they work sometimes -- it's not reliable. 即使它们有时起作用-这也不可靠。 And as pointed out by the other answer: 正如另一个答案所指出的那样:

Visual Studio macros like $(SolutionDir) don't work in MSBuild. 像$(SolutionDir)这样的Visual Studio宏在MSBuild中不起作用。 You can use project properties instead. 您可以改用项目属性。

Source: Code Generation in a Build Process 来源: 构建过程中的代码生成

$(ProjectDir) The directory of the project (defined as drive + path); $(ProjectDir)项目的目录(定义为驱动器+路径); includes the trailing backslash '\\'. 包括结尾的反斜杠“ \\”。

$(SolutionDir) The directory of the solution (defined as drive + path); $(SolutionDir)解决方案的目录(定义为驱动器+路径); includes the trailing backslash '\\'. 包括结尾的反斜杠“ \\”。

Note that: 注意:

You can use these macros anywhere in a project's Property Pages dialog box where strings are accepted. 您可以在接受字符串的项目的“属性页”对话框中的任何位置使用这些宏。

Source: Macros for Build Commands and Properties 来源: 构建命令和属性的宏

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM