$(SolutionDir)变量可以在Visual Studio Publish Profile中使用吗?
使用Visual Studio 2017,在解决方案资源管理器中,我右键单击C#.NET核心项目,然后选择“发布...”。我创建一个发布个人资料,将应用程序发布到文件夹或文件共享。结果是一个配置文件,其默认目标位置是绝对路径“ [Project Directory] \ bin \ Release \ netCoreApp2.1 \ Publish \”,例如在以下片段中。
Visual Studio生成.pubxml
文件以存储该发布配置文件,其中目标位置存储在< lt; lt; prublishdir>
中标签。例如:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<TargetFramework>netcoreapp2.1</TargetFramework>
<PublishDir>F:\work\foo\bin\Release\netcoreapp2.1\publish\</PublishDir>
</PropertyGroup>
</Project>
我希望是在&lt; PublishDir&gt;
标签的值中使用一个变量,例如$(solutiondir)
变量。我可以手动编辑.pubxml
文件以注入变量。例如:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
...
<PublishDir>$(SolutionDir)\publish\</PublishDir>
</PropertyGroup>
</Project>
但是,当我下一个将项目加载到Visual Studio中时,该变量要么被忽略,要么具有空值,例如在以下片段中。
有没有办法在发布配置文件中使用变量?
Using Visual Studio 2017, in the solution explorer, I right-click on a C# .Net Core project and select "Publish...". I create a publish profile that publishes the app to a folder or file share. The result is a profile whose default target location is an absolute path "[project directory]\bin\Release\netcoreapp2.1\publish\", such as in the following snippet.
Visual Studio generates a .pubxml
file to store that publish profile, where the target location is stored in a <PublishDir>
tag. For example:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<TargetFramework>netcoreapp2.1</TargetFramework>
<PublishDir>F:\work\foo\bin\Release\netcoreapp2.1\publish\</PublishDir>
</PropertyGroup>
</Project>
What I would prefer is to use a variable in the value of the <PublishDir>
tag, such as the $(SolutionDir)
variable. I can manually edit the .pubxml
file to inject a variable. For example:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
...
<PublishDir>$(SolutionDir)\publish\</PublishDir>
</PropertyGroup>
</Project>
However, when I next load the project in Visual Studio, that variable is either ignored, or has a empty value, such as in the following snippet.
Is there a way to use variables in the publish profile?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用VS2019也有类似的问题。只有对我有用的东西,环境变量之类的环境变量(例如
$(windir)
)以及pubxml
上方的属性中的属性,其中需要的是
webpublishmethod
webpublishmethod < /code>不是
publishurl
的一部分,因为它在publishurl
下方。不知道
f:\ work \ foo \ bin \
,但是您可以尝试配置和targetFramework
Release \ netCoreapp2.1
Had a similar problem using VS2019. Only things that worked for me where environment variables like
$(windir)
and Properties in thepubxml
above the line where they are needed e.g.The resulting PublishUrl was
WebPublishMethod
is not part ofPublishUrl
because it's belowPublishUrl
.Don't know about
F:\work\foo\bin\
but you could try Configuration andTargetFramework
forRelease\netcoreapp2.1