I have developed a plugin to control the enable state of a specified menu and ribbon control in Office 2016.
XML files follow this format:
<?xml version="1.0" encoding="utf-8" ?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<commands>
<command idMso="FileSendAsAttachment" enabled="false"/>
<command idMso="FileEmailAsPdfEmailAttachment" enabled="false"/>
<command idMso="FileEmailAsXpsEmailAttachment" enabled="false"/>
<command idMso="FileInternetFax" enabled="false"/>
...
</commands>
<ribbon>
</ribbon>
<backstage>
</backstage>
</customUI>
After installing the add-in, depending on the policy, the agent may need to temporarily enable certain menus.
So, I modified only the enable property of the control in the XML file and restarted Office, but all the menus are enabled.
(However, when I replace it with the original XML file, it is marked as disable again.)
My addin was registered via regsvr32.exe, and the registry was written in HKCU.
(Windows is 64bit, Office 2016 is 32bit.)
Has anyone had a similar problem?
What is causing this?
After installing the add-in, I modified the XML file using notepad. And I found that it is stored in utf-8 encoding way.
I noticed that the format is broken because the BOM is inserted in the first byte of the XML file. If you save the file as ANSI, it works fine.
I hope you will not make the same mistake as me !
use utf-16
<commands>
<command idMso="FileSendAsAttachment" enabled="false"/>
<command idMso="FileEmailAsPdfEmailAttachment" enabled="false"/>
<command idMso="FileEmailAsXpsEmailAttachment" enabled="false"/>
<command idMso="FileInternetFax" enabled="false"/>
...
</commands>
<ribbon>
</ribbon>
<backstage>
</backstage>
</customUI>
Related
I am working on a a test solution through the CodedUITest framework on visual studio 2017 enterprise.
I am using a runsettings file as detailed here : https://learn.microsoft.com/fr-fr/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file?view=vs-2019#example-runsettings-file
I set the mediarecorder in order to get the video even when the test passed:
<DataCollector uri="datacollector://microsoft/VideoRecorder/1.0" assemblyQualifiedName="Microsoft.VisualStudio.TestTools.DataCollection.VideoRecorder.VideoRecorderDataCollector, Microsoft.VisualStudio.TestTools.DataCollection.VideoRecorder, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" friendlyName="Screen and Voice Recorder">
<!--Video data collector was introduced in Visual Studio 2017 version 15.5 -->
<Configuration>
<!-- Set "sendRecordedMediaForPassedTestCase" to "false" to add video attachments to failed tests only -->
<MediaRecorder sendRecordedMediaForPassedTestCase="true" xmlns="">
<ScreenCaptureVideo bitRate="512" frameRate="2" quality="20" />
</MediaRecorder>
</Configuration>
</DataCollector>
But I did not find where the video file is stored.
Any idea where I can find it? Is it possible to specify a folder path where we want to store the record?
Thx,
Check further up in the runsettings file: Recordings are stored underneath the ResultsDirectory
<RunSettings>
<RunConfiguration>
...
<!-- Path relative to directory that contains .runsettings file-->
<ResultsDirectory>.\TestResults</ResultsDirectory>
If I start a new web api project, the appsettings files are grouped together. However, I'm creating a working project from the console app template and when I create the appsettings files manually, the do not group together. I think back in older versions, there was something I'd put in the csproj file, but I don't know how to do it in .net core and I'm not seeing anything in properties or configurations
In the project file of your solution you can edit or add an <ItemGroup> element within the <Project> element. This worked for me:
<ItemGroup>
<Content Include="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="appsettings.*.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<DependentUpon>appsettings.json</DependentUpon>
</Content>
</ItemGroup>
Please Note that my console project targets .Net Core 2.0 and is running in Visual Studio Pro 2017 Version 15.7.5.
Also, if your Solution Explorer doesn't immediately refresh try unloading and reloading the project.
Using an <ItemGroup> with <Content> as suggested gave me an error (in Visual Studio 2019) about "Duplicate 'Content' items included". It turns out the .NET SDK includes 'Content' items from your project directory by default. Setting the EnableDefaultContentItems property to false seems a bit rigid, so now I include the items as <None>.
<ItemGroup>
<!-- Group AppSettings in Console project. Use None to prevent "Duplicate 'Content' items were included" when using (default) EnableDefaultContentItems=true -->
<None Include="appsettings.*.json">
<DependentUpon>appsettings.json</DependentUpon>
</None>
</ItemGroup>
This does show the files grouped, but shows their properties with Build Action 'None' and 'Do Not Copy' in the Solution-explorer, so I guess that's the price for wanting them to group?
FWIW: a file-nesting rule as suggested in appsettings-json-not-in-hierarchy
will not show the files as grouped/nested, but it will make it collapse if the solution-explorer collapse-button is pressed.
You just need to click the File Nesting icon, and choose "Web"
Goal
I want to be able to run my unit tests remotely on another machine since they interact with the UI of another application. For clarity these tests are not Coded UI Tests, they are tests methods that use FlaUI to interact with the desktop.
Problem
I can't get the Visual Studio Test Controller and Test Agent to work with MSTest V2. When I set the .runsettings file to use the .testsettings file and to ForcedLegacyMode like the documentation says here I get the following warnings and no tests are loaded into the test explorer.
[11/22/2017 9:54:12 AM Warning] Index was outside the bounds of the array.
[11/22/2017 9:54:13 AM Warning] Index was outside the bounds of the array.
[11/22/2017 9:54:13 AM Warning] Index was outside the bounds of the array.
[11/22/2017 9:54:14 AM Warning] Warning : A testsettings file or a runsettings with a ForcedLegacyMode set to true is not supported with the MSTest V2 Adapter.
I am hoping I am just missing some setting I can put into my .runsettings file that will allow me to specify the url for my Test Controller.
Settings
Here are my .runsettings and .testsettings files for reference. These settings successfully connect to the machine but when I build my test runner no longer finds and tests to run.
.runSettings
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<!-- Configurations that affect the Test Framework -->
<RunConfiguration>
<MaxCpuCount>1</MaxCpuCount>
<!-- Path relative to solution directory -->
<ResultsDirectory>.\TestResults</ResultsDirectory>
<!-- [x86] | x64
- You can also change it from menu Test, Test Settings, Default Processor Architecture -->
<TargetPlatform>x86</TargetPlatform>
<!-- Framework35 | [Framework40] | Framework45 -->
<TargetFrameworkVersion>Framework40</TargetFrameworkVersion>
</RunConfiguration>
<!-- Configurations for data collectors -->
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Configuration>
<CodeCoverage>
<ModulePaths>
<Exclude>
<ModulePath>.*CPPUnitTestFramework.*</ModulePath>
</Exclude>
</ModulePaths>
<!-- We recommend you do not change the following values: -->
<UseVerifiableInstrumentation>True</UseVerifiableInstrumentation>
<AllowLowIntegrityProcesses>True</AllowLowIntegrityProcesses>
<CollectFromChildProcesses>True</CollectFromChildProcesses>
<CollectAspDotNet>False</CollectAspDotNet>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
<!-- Parameters used by tests at runtime -->
<TestRunParameters>
</TestRunParameters>
<!-- Adapter Specific sections -->
<!-- MSTest adapter -->
<MSTest>
<MapInconclusiveToFailed>True</MapInconclusiveToFailed>
<CaptureTraceOutput>false</CaptureTraceOutput>
<DeleteDeploymentDirectoryAfterTestRunIsComplete>False</DeleteDeploymentDirectoryAfterTestRunIsComplete>
<DeploymentEnabled>False</DeploymentEnabled>
</MSTest>
</RunSettings>
.testsettings
<?xml version="1.0" encoding="UTF-8"?>
<TestSettings name="rmoqa01" id="076be28c-d18b-46bf-ad20-4d43ec821ea4" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
<Description>These are default test settings for a local test run.</Description>
<RemoteController name="10.2.0.101" />
<Execution location="Remote">
<Hosts skipUnhostableTests="false">
<VSSDKTestHostRunConfig name="VS IDE" HiveKind="DevEnv" HiveName="15.0_c9b36733" xmlns="http://microsoft.com/schemas/VisualStudio/SDK/Tools/IdeHostAdapter/2006/06" />
</Hosts>
<TestTypeSpecific>
<UnitTestRunConfig testTypeId="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b">
<AssemblyResolution>
<TestDirectory useLoadContext="true" />
</AssemblyResolution>
</UnitTestRunConfig>
</TestTypeSpecific>
<AgentRule name="AllAgentsDefaultRole">
</AgentRule>
</Execution>
<Properties />
</TestSettings>
I opened a issue on the mstest github page and after looking at the source code generating my warning I am seeing it looks like there is probably no work around to this. Here is the source code I was looking at in the MSTestDiscover.cs.
// Scenarios that include testsettings or forcing a run via the legacy adapter are currently not supported in MSTestAdapter.
if (MSTestSettings.IsLegacyScenario(logger))
{
return;
}
EDIT: 10/28/2018
The issue I linked to above was updated with the following response.
There are no plans to have remote execution capability through MSTVest2. You can use the test task in VSTS which supports distributed execution on multiple agents. https://learn.microsoft.com/en-us/vsts/pipelines/test/set-up-continuous-test-environments-builds?view=vsts
I'm working on a graphic installer for a java project using izPack 4.3.4, the installation goes well but when I try to uninstall it by clicking on his reference in "Programs and Features" window it shows the message:
Error: Unable to access jarfile C:\Program Files (x86)\myproject\uninstaller\uninstaller.jar
The fact is that I choosed to put and rename the uninstaller in the root install path of my program and not in \uninstaller dir. See the XML:
<info>
...
<uninstaller name="uninstall.jar" write="yes" path="${INSTALL_PATH}" />
...
</info>
And, in fact, uninstall.jar file is created in C:\Program Files (x86)\myproject\ and it works if I double click on it or throught the Start Menu. I think izpacks writes the wrong data in the Windows's registry to reference it in "Programs and Features"... but I don't know why...
If you're installing using IZPack on Windows, you can (should) have a RegistrySpec.xml. That guy writes all the registry entries you need. Windows looks for a Registry Value "UninstallString" as the file to run to kick off your uninstall, and you likely need to overwrite that. For example on mine:
<pack name="UninstallStuff">
<!-- Special "pack", if not defined an uninstall key will be generated automatically -->
<value name="UninstallString"
keypath="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$APP_NAME"
root="HKLM"
string="$INSTALL_PATH\uninstall\uninstaller.cmd"/>
<pack name="UninstallStuff">
I am trying log some entries in a log file (Log.Trace / Log.Debug) while my VS unit test runs. I have also copied the file NLog.config to out directory through DeploymentItem attribute over class. Still my log file is not created. Any help as to how can we log entries in a file same as we do for normal web application.
I've just found a solution to this problem:
Add the App.config file to yout unit test project with the following contents:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/>
</configSections>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target name="debugLog" xsi:type="Console" />
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="debugLog"></logger>
</rules>
</nlog>
</configuration>
You may put any configuration you wish as with NLog.config file.
Unfortunately that is the only XML solution at the time. It is not only about Unit Testing, though. NLog.config does not work with just any Console Application.
Do not know if it is by design or just an oversight. Anyway I would not say that moving NLog.config to App.config section is any way satisfactory =/
Maybe it is worth to notice that there is a possibility of configuring nlog directly from code, what could be helpful in some scenarios.
One could be also glad to find nlog debug option, that will log the whole process of processing configuration file, registering targets and so on...
To turn it on, just add internalLogFile and internalLogLevel attributes to nlog element:
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" internalLogFile="C:/logs/nlog.txt" internalLogLevel="Debug">
or from code:
InternalLogger.LogFile = #"c:\logs\nlog.txt";
InternalLogger.LogLevel = LogLevel.Trace;