在 MsBuild 中声明动态配置文件路径

发布于 2024-08-17 20:11:37 字数 402 浏览 3 评论 0原文

目前,我正在尝试将文件复制到用户配置文件内的某个位置,但在声明动态配置文件名称时遇到问题,例如:

<Target Name="CopyScript">
    <MsBuild Projects="JsProject.csproj" />
    <Copy SourceFiles="$(ProjectDir)\myScript.js" DestinationFolder="$(systemdrive)\Documents and Settings\$(userProfileName)" />
</Target>

声明动态用户配置文件名称的语法是什么?我是否必须从某个地方获取配置文件名称,或者是否有另一个 MsBuild 任务可以为我找到它?

谢谢。

Currently I'm trying to copy a file to a location inside a user's profile, but hit a problem with declaring dynamic profile name, e.g.:

<Target Name="CopyScript">
    <MsBuild Projects="JsProject.csproj" />
    <Copy SourceFiles="$(ProjectDir)\myScript.js" DestinationFolder="$(systemdrive)\Documents and Settings\$(userProfileName)" />
</Target>

What is the syntax for declaring a dynamic user profile name? Do I have to get the profile name from somewhere, or is there another MsBuild task which will find it for me?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初雪 2024-08-24 20:11:37

您应该能够通过 HOMEDRIVE 和 HOMEPATH 环境变量获得此信息。例如:

<Project ToolsVersion="3.5" DefaultTargets="Demo" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

    <PropertyGroup>
  <UserDir>$(HOMEDRIVE)$(HOMEPATH)</UserDir>
 </PropertyGroup>

  <Target Name="Demo">
 <Message Text="UserDir : $(UserDir)" Importance="High" />
  </Target>

</Project>

当您执行 Demo 目标时,您应该获取当前用户主目录的路径。

You should be able to get this with the HOMEDRIVE and HOMEPATH env variables. For example:

<Project ToolsVersion="3.5" DefaultTargets="Demo" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

    <PropertyGroup>
  <UserDir>$(HOMEDRIVE)$(HOMEPATH)</UserDir>
 </PropertyGroup>

  <Target Name="Demo">
 <Message Text="UserDir : $(UserDir)" Importance="High" />
  </Target>

</Project>

When you execute the Demo target you should get the path to the current users home directory.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文