Windows 代码所代表的用户的登录名 运行

Windows logon name of the user on whose behalf the code is being run

我用谷歌搜索并检查了 2 个资源。

我 msbuild.exe 调用了一个 myproject.proj 文件。

有没有办法报告身份运行进程的IIDentity?

我在 "Common MSBuild Project Properties" 或 "Jenkins Environment Variables" 下没有找到任何东西。

我知道我可以编写一个自定义任务来结束这个调用 (https://msdn.microsoft.com/en-us/library/system.security.principal.windowsidentity.name%28v=vs.100%29.aspx),但我希望有更简单的东西。

"Common MSBuild Project Properties" : https://msdn.microsoft.com/en-us/library/bb629394.aspx

"Jenkins Environment Variables" : https://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project#Buildingasoftwareproject-below

您可以在 exec 任务中尝试 运行 whoami 命令 如:

<Exec Command="whoami" ConsoleToMSBuild="true">
  <Output TaskParameter="ConsoleOutput" PropertyName="UserName" />
</Exec>

<Message Text="Hello $(UserName), this is your script"/>

可以在此处找到有关该命令的更多信息

whoami cmd