.net – 在构建服务器上为Windows Store单元测试自动开发者许可
发布时间:2020-12-13 20:08:44 所属栏目:Windows 来源:网络整理
导读:对于 Windows Store应用程序,需要开发人员许可证才能运行单元测试,这对个人计算机上的个人开发人员来说是非常适用的. 但是,对于构建服务器上的持续集成过程,我们真的需要自动获取许可证的能力. Microsoft提供了一个命令行工具,但它仍然创建一个交互式窗口,这
对于
Windows Store应用程序,需要开发人员许可证才能运行单元测试,这对个人计算机上的个人开发人员来说是非常适用的.
但是,对于构建服务器上的持续集成过程,我们真的需要自动获取许可证的能力. Microsoft提供了一个命令行工具,但它仍然创建一个交互式窗口,这会打破这个过程. TailoredDeploy.exe AcquireDeveloperLicense 有谁知道其他任何方式自动获得开发许可证?如果需要手动设置,产生新的构建节点将是地狱.他们每个的VPN.
我被建议使用
UI Automation,这就是我迄今为止所创造的:
using System.Diagnostics; using System.Threading; using System.Windows.Automation; class Program { static void Main(string[] args) { var processStartInfo = new ProcessStartInfo(@"C:Program Files (x86)Microsoft Visual Studio 11.0Common7IDETailoredDeploy.exe","AcquireDeveloperLicense"); var process = Process.Start(processStartInfo); process.WaitForInputIdle(); Thread.Sleep(1000); var agreementWindow = AutomationElement.RootElement.FindFirst(TreeScope.Children,new PropertyCondition(AutomationElement.ProcessIdProperty,process.Id)); var iAgreeButton = agreementWindow.FindAll(TreeScope.Children,Condition.TrueCondition)[0] .FindAll(TreeScope.Children,Condition.TrueCondition)[2]; var buttonPattern = iAgreeButton.GetCurrentPattern(AutomationPattern.LookupById(InvokePattern.Pattern.Id)) as InvokePattern; buttonPattern.Invoke(); Thread.Sleep(10000); var processes = Process.GetProcessesByName("dllhost"); var credentialsWindows = AutomationElement.RootElement.FindAll(TreeScope.Children,processes[0].Id)); if (credentialsWindows[0].Current.Name == "Developer License") { var credentialsPane = credentialsWindows[0].FindAll(TreeScope.Children,Condition.TrueCondition)[0] .FindAll(TreeScope.Children,Condition.TrueCondition); var usernameTextBox = credentialsPane[3].GetCurrentPattern(AutomationPattern.LookupById(ValuePattern.Pattern.Id)) as ValuePattern; usernameTextBox.SetValue("username@outlook.com"); var passwordTextBox = credentialsPane[5].GetCurrentPattern(AutomationPattern.LookupById(ValuePattern.Pattern.Id)) as ValuePattern; passwordTextBox.SetValue("password"); var loginButton = credentialsPane[8].GetCurrentPattern(AutomationPattern.LookupById(InvokePattern.Pattern.Id)) as InvokePattern; loginButton.Invoke(); Thread.Sleep(10000); var finishUpProcesses = Process.GetProcessesByName("TailoredDeploy"); var finishWindow = AutomationElement.RootElement.FindFirst(TreeScope.Children,finishUpProcesses[0].Id)); var lastItems = finishWindow.FindAll(TreeScope.Children,Condition.TrueCondition)[0] .FindAll(TreeScope.Children,Condition.TrueCondition); var closeButton = lastItems[3].GetCurrentPattern(AutomationPattern.LookupById(InvokePattern.Pattern.Id)) as InvokePattern; closeButton.Invoke(); } } } 要使用它,需要一个app.manifest才能在升级模式下运行: <?xml version="1.0" encoding="utf-8"?> <asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> <security> <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> </requestedPrivileges> </security> </trustInfo> <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> <application> </application> </compatibility> </asmv1:assembly> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- “允许计算机关闭此设备以节省电量” – Windows vNIC
- 在Windows 2008 Server上同步时间的最佳方法
- 忽略Windows Genuine Advantage安装弹出窗口的任何副作用
- [2]窗口程序的创建
- 反汇编Microsoft Visual Studio 2003编译器输出
- 用于打开“配置高级用户配置文件属性”的命令(Windows 7)
- active-directory – 如何仅将组策略应用于特定IP范围内的客
- windows-7 – 如何用脚本更改Win7主卷?
- windows-8 – Windows 8.1应用程序内搜索控制和搜索窗格(搜
- windows-7 – dpinst/DifX不会静默安装签名驱动程序