简体   繁体   中英

Visual Studio Publish MSdeploy $(SolutionDir)

I'm having an annoying issue with MSDeploy and Visual Studio's publish profile. 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. 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

Visual Studio macros like $(SolutionDir) don't work in MSBuild. You can use project properties instead.

Use $(ProjectDir) (safer, project level property) or $(MSBuildProjectDirectory) (safest, always exist)

See: $(SolutionDir) MSBuild property incorrect when running Sandcastle Help File Builder via CMD and getting the value of $(ProjectDir), $(SolutionDir) in a vcproj file

It looks like $SolutionDir does (sometimes) work with MSBuild, but only if you're building from the solution file. It is the same thing as $ProjectDir for the most part.

But you're not supposed to be able to use them in 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. You can use project properties instead.

Source: Code Generation in a Build Process

$(ProjectDir) The directory of the project (defined as drive + path); includes the trailing backslash '\\'.

$(SolutionDir) The directory of the solution (defined as drive + path); 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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