Launch an Extension command at Visual Studio 2022 launch? - visual-studio-extensions

I've written a VS 2022 Extension containing commands that I'd like to run at the launch of Visual Studio 2022.
The command run fine if executed from a menu item but I cannot determine where a call to the command should be placed if I wish it to be called immediately after VS 2022 starts.
The VS commandfile functions New() and InitializeAsync() do not appear to be called until the first command is launched by a menu item (because the extension isn't loaded until called upon).
Is there a method of making the extension ready/initialized so it can run a command at startup, or to run the command at startup and force it to initialize?

You can configure an AsyncPackage to auto-load with the instructions here. Note there is some asynchrony so if you need it to run precisely at certain point you may have issues; we limit the ability for that because when everybody writes their package to do something on startup, Visual Studio startup then takes forever.

Related

How to convert from VS web deploy to command line MS deploy

Within Visual Studio, I use Web Deploy.
Within the settings, it asks for 4 fields to be filled one (and 1 optional)
I am guessing, behind the scenes, it is calling msdeploy.exe and passing them as command line arguments
I'm struggling to map these across as I want to use
shell: cmd
run: '"C:/Program Files (x86)/IIS/Microsoft Web Deploy V3/msdeploy.exe"
-verb:sync
-allowUntrusted
-source:contentPath="%CD%\myDomain.Ui\bin\Release\netcoreapp3.1\"
-dest:contentPath=domain,computerName="<server>:443/msdeploy.axd?site=<site name>",username="<user name>",password="<password>",authtype="Basic"'
As you can see, source:contentPath uses the actual path and this works fine in GitHub actions. I'm having issues with the dest: part. In the example above, I've used the titles (so instead of myUserName, I've used as it shows in the screenshot)
I have 2 questions.
When I click "publish" within Visual Studio, if it really is just calling msdeploy.exe, then is it possible to show this in the output. If I knew how to do that, I may be able to answer my own question
Have I mapped them correctly
As for how to see more details, this KIND OF works:
Visual studio 2017 Verbose publish
The relevant part is
To change the amount of information included in the build log On the menu bar, choose Tools, Options.
On the Projects and Solutions page, choose the Build and Run page.
In the MSBuild project build output verbosity list, choose one of the following values, and then choose the OK button.
And then, at the very end of the build, search for MsDeploySourceProviderSetting
You can then see the details! This gives some of the values, but not all!! It doesn't really answer the question! However, it got me part way there
It needed to be
-dest:contentPath=<site name>,computerName="<server>:443/msdeploy.axd?site=<site name>",username="<user name>",password="<password>",authtype="Basic"'
EG, my website ULR is https://example.com and in IIS, it is set up as MyWebsite
-dest:contentPath=<MyWebsite>,computerName="https://examplecom:443/msdeploy.axd?site=MyWebsite",username="<user name>",password="<password>",authtype="Basic"'
Also, if you do use VS as I did, it may give you a different port, so be aware that 443 may not be right!!

How can we redirect 'RobotTempDir' folder to save at different location on windows 10?

I am working with Robot Framework using RED editor on Eclipse IDE. When i ran a Robot test case an error as shown in the screenshot has occurred
Upon tracing back my actions, I have noticed that RobotTempDir... got deleted from Temp folder. I restored that folder and ran the test case. Then it executed successfully.
In future there are chances that while cleaning temp folder contents, RobotTempDir... may get deleted unknowingly. Is there a way to redirect this RobotTempDir... contents to save in a different location?
I looked into the C:\Python36\Lib\site-packages\robot path and didn't find any files where i can change/update Robot temp folder details.
The TestRunnerAgent.py is not part of the Robot Framework application but instead comes with the RED plugin. It is part of their Robot Run functionality which allows it to retrieve information from Robot Framework while it is running.
This information is then displayed in the Eclipse Message Log panel or used when using the RED debugger functionality.
In my view this file is generated every time Eclipse is started and I think the only time this error would occur is when that file/folder is deleted while Eclipse is running. Restarting Eclipse should fix this.
TestRunnerAgent.py is custom listener which is attached to Robot process to report back to RED what is happening during test execution. For normal test runs,this is Execution View information,also Message Log stuff printed there. For Debug run, TestRunnerAgent.py allows to control execution process (breakpoint stop,stepping) and changing internals of Robot (state of variables).
It is embedded in RED package,and as you said, it is temporary placed in Temp dir for execution. If you would like to check source,either check jar file: org.robotframework.ide.core-functions-0.0.1-SNAPSHOT.jar or on GitHub: https://github.com/nokia/RED/tree/master/src/RobotFrameworkCore/org.robotframework.ide.core-functions/src/main/python/scripts
Back to your issue:
RED starts Robot execution with following command:
<selected python interpreter> -m robot.run --listener <path to TestRunnerAgent.py> <details what to run and other miscs>
There is no indication of error such error in TestRunnerAgent.py although there is in RobotLaunchConfigurationDelegate.java which tries to start Robot using interpreter in current Project configuration. I assume that there is something wrong in your env setup (either in RED or in OS)
I would suggest to check following:
check if you selected proper python interpreter with installed Robot (from Windows->Preferences-> RobotFramework ->Interpreters
check if your project looks similar as here: http://nokia.github.io/RED/help/user_guide/quick_start.html
you can try to use custom script to catch robot execution command and remove --listener part to validate if this is the culprit: http://nokia.github.io/RED/help/user_guide/launching/local_launch_scripting.html
there should be command in Console View - try to run it by yourself

Simple Javafx application not launching from eclipse <exit value: -1073740791>

This is a frustrating one that i am sure has a simple solution but i can't figure out which setting changed which is causing my javafx application not to launch.
The first javafx application that i ran on my workstation through eclipse oxygen worked fine. I imported a project that was prebuilt to display fractals and added "javafx/**" as accessible to my build path and i was able to launch it successfully.
Since then, I've tried loading other javafx projects to my workspace and running them with the same build path but nothing appears after i try to run the application.
I made sure to be in the class that extends application with the launch in it and that the build path is set but all i get when i try to run it in debug any javafx application terminates right away with the following exit code:
<disconnected>org.hameister.javafx.fractal.JavaFXFractal at localhost:49944
<terminated, exit value: -1073740791>C:\Program Files\Java\jdk1.8.0_161\bin\javaw.exe
At first i thought it was the code in the new projects but when i try to run the original fractal project again it gives me the same thing.
Does anyone have a clue how i can fix this?
Thank you!
Update:
I reinstalled the jdk (jdk-8u161-windows-x64) and eclipse (Oxygen.2 Release (4.7.2)) and am working out of a new workspace.
When I debug the applications, I get a quick stack that displays:
-Daemon Thread [QuantumRenderer-0] (Running)
-Daemon Thread [thread-1] (Running
-Thread [WindowsnativeRunLoopThread] (Running)
Then the stack is empty with only the terminated exit value from above.
It's as though I hit some hotkey or button that is no longer allowing applications to visually appear. Console based Java applications run fine.

OpenCover - measuring coverage against running ASP.NET application

I'd like to measure the coverage from UI integration tests, so I need to apply OpenCover to the running ASP.NET application, not the test execution. (I already got coverage for unit tests by running OpenCover on VSTest.Console.Exe.)
When I launch the app from Visual Studio 2013, it looks like it's running iisexpress.exe. How could I figure out what command line VS is running so I could pass the same command line to OpenCover?
OK, I figured it out.
The right command line to use is iisexpress.exe /site:[sitename] where sitename matches whatever your web project is called in Visual Studio. Specifying just the path to the project will not provide the desired results.
And to get test coverage with OpenCover, you would run
OpenCover.console.exe -target:iisexpress.exe -targetargs:"/site:sitename" -register:user
assuming you're in the same directory as your web project build with the PDB files, otherwise you may need to use -targetdir argument to OpenCover

HP Fortify scans get ASP Pre-Compilation error

I am using Visual Studio 2012 and HP Fortify 4.21 with the latest rule packs.
The code (C#) lives on the same machine that has HP Fortify and I am only using AWB not SCC. The code successfully builds when the developer does the build, but when I try to scan with Fortify I get an error.
ASP Pre-compilation error
This error happens whether I am launching from VS or from command line. The logs show no errors or warnings, but stating at the end that there is nothing to store, so a fpr file is never created. If I run the scan from Audit Workbench it crashes only stating that it cannot create the build ID.
I did find a suggestion (below) to resolve the ASP issue but it fails and does not create the fpr file to be able to run the last line (to do the scan).
I appreciate any assistance!
Step 1: Clean
sourceanalyzer -b "Build ID" -clean
Step 2: Translation/Build
sourceanalyzer -b "Build ID" -Xmx1280M -Xss8M -debug -logfile trans.log devenv "Sample.sln" /Rebuild Debug
Step 3: Analysis
sourceanalyzer -b "Build ID" -Xmx1280M -Xss8M -debug -logfile scan.log -scan -f Results.fpr
I was running into this issue and this took care of my problem.
Step 1. Click the "BUILD" tab
Step 2. Click "Clean Solution"
Step 3. Most likely two folders appeared in the Solution Explorer (bin and obj). Right click each one and delete it, doesn't matter what order you do it in.
Step 4. Click the "BUILD" tab
Step 5. Click "Rebuild Solution"
Step 6. Try to run FORTIFY again
Extra steps
Step 7. If it still doesn't work check your web.config for errors. The project will build with errors but will cause the precompilation to fail with Fortify.
Step 8. Try allocating more RAM to Fortify by going to HP Fortify -> Options -> Project Settings -> Memory (MB) -> 1024 (or higher).
I've run into similar problems. Try it on another machine. Sometimes that makes it work. When it hasn't it has been due to a Fortify bug. Working with Fortify support has helped me track the problem down. HP files a bug on it though I don't believe it helps. That said, once I know what construct in the file has caused the failure I've been able to modify the file to get Fortify to complete.
Sorry I don't have more help.
The problem is with one or more of your ASPX files. For dotnet web forms the ASPX pages are not compiled by Visual Studio, they are compiled dynamically on the server. In order for Fortify to scan that code, it is calling the ASPNET_compiler to compile your ASPX files. Pass -debug from the command line and then look in the log for a call to ASPNET_compiler. You can copy those arguments and then run them in the Visual Studio command prompt to find the ASPX file that is causing the problem. Keep in mind that when passing ASPNET_compiler a directory to compile, it dies when it finds the first error. You may have to run it a few times to find all of the errors.
Check the Analysis Information Tab in AWB for a related scan error. Also look at the scan log file for a related entry there as well.
If Eric is correct, you may want to put sourceanalyzer into the build script in case the problem re-appears.
step 1. - click "build" tab
step 2. - click "clean solution"
step 3. - 2 folders appeared in solution explorer (bin , obj). right click
each 1 , delete it, doesn't matter order in. step 4. click "build" tab step 5. click "rebuild solution" step 6. try run fortify again
extra steps
step 7. - f still doesn't work check web.config errors. project build errors cause precompilation fail fortify.
step 8. - try allocating more ram fortify going hp fortify -> options -> project settings -> memory (mb) -> 1024 (or higher).
The below link helped to solve my problems.
http://nayviocde12.blogspot.be/2012/08/aspnet-hp-fortify-scans-get-asp-pre.html
Fortify SCA version 16.20 and after
Starting with Fortify SCA version 16.20, ASP.Net code no longer uses the Microsoft aspnet_compiler.exe so this particular issue will not occur again.
Before Fortify SCA version 16.20
My preferred method of debugging precompiler issues is to add this command into the post-build event of the web project in Visual Studio, that way the error shows up in the error list.
"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_compiler.exe" -v / -p $(ProjectDir)
Another thing to keep in mind, if you have files that are not part of the solution but are part in the web projects directory, the aspnet_compiler will still read them.
I find this situation common when developers would excluded files from Visual Studio. This does not delete them. Or if they delete them, then delete through the Visual Studio interface but not from the underlying source code repository and they just get downloaded again on checkout.
An easy way to check this would be to turn on Show All Files in the Visual Studio Solution Explorer window.

Resources