Is there a way to store a list of commands in Visual Studio for Package Manager Console - visual-studio

We're switching from a classic Desktop application project, where everything fitted nicely within Visual Studio, to an Angular Web Project, where everything seems to be scattered over different environments all over the place.
One of the changes is nuget packages, which makes me feel like we're back in the 80's, where everything needs to be done with commands in Command Prompt, instead of just using buttons and menus. I find this slightly annoying, as now you have to remember a long list of commands where previously you could just remember a button's location.
Is there a place where you can store a list of commands that you can browse in your Package Manager Console? For instance, if I forget the command that script my model into SQL Scripts, I can just browse the list, instead of looking for the email where a colleague told me what it was?

The Package Manager Console is a PowerShell session, so you could create a PowerShell script Module with everything in it.
And even load from your profile (for package manager specific use file: run $profile.CurrentUserCurrentHost in the console to get the path).

Related

How do I work around the "The process cannot access the file .ISPAC because it is being used by another process" error?

I executed an SSIS package using SSDT and Visual Studio. When I try to execute another package I get an error saying "The process cannot access the file XXXX.ispac because it is being used by another process". I have tried rebooting but that is a pain in the behind. How can I work around this error?
While developing an SSIS package I got the error “The process cannot access the file ‘.ispac’ because it is being used by another process”*.
Tried to close SSDT and run it again but, we still got the same error while compiling. Then, after searching over internet, we got the solution:
Solution :
Go to Task Manager–> Details Tab.
Locate the process “DtsDebugHost.exe“.
Kill this process.
There might be multiple instances of this process. Kill all of them.
After doing this, I tried to compile the package again and it was successful.
You might check your patch level. I saw this much more frequently with the 2015 release of SSDT but hasn't bit me too often since then.
Finding and killing a process
Sysinternals has an excellent tool called Process Explorer. It's free, doesn't require an install and helps you see what all is happening on your computer. In this case, you want to find the process that has its grubby finger on your file (MyProject.ispac) and then kill it.
https://helpcenter.gsx.com/hc/en-us/articles/115015880627-How-to-Identify-which-Windows-Process-is-Locking-a-File-or-Folder
A different approach that doesn't require getting Process Explorer running is to change your build from Development to Release (and back again).
Chicken Sandwich No Pickles asks via comments
How can I convert from Development to Release?
In your tool bar, click where you see Development in the dropdown (or right click the solution in Solution Explorer)
In Configuration manager, you may/may not have a listing available under Configuration. Earlier versions of SSIS projects had dev/release configurations predefined but it looks like newer ones do not. If you do not have another option, make one via <New...>
Copy the values from the Development configuration et voilà!
Now when you debug, ProjectFolder/bin/Release will exist and the dtsdebughost.exe will latch onto that file and release the pointers to ProjectFolder/bin/Development/Project.ispac
Here's a simple script you can run in powershell to kill all ssis debug process "DtsDebugHost.exe" and unlock the ispac file.
unlock_ispac.ps1
# if ssis error with 'The process cannot access the file ‘.ispac'
# run this file in powershell
get-process | foreach {
$pName = $_
if($pName.Name -eq "DtsDebugHost") {
$pName.Kill()
}
}

Windows installer is too clever, tries to repair when tester deletes config file

Our application is deployed to the target machine with an msi file. All works nicely. Our tester has gone through his plan, and one of the tests requires deleting the application's configuration file. The application is designed to alert the user with a dialog on startup saying "missing config". However, what happens is that - somehow! - the software starts the installer again and retrieves the missing file from the msi! Which is nice, but not what we want. How do we disable that behaviour?
without going into much depth of the windows installer mechanics (if you interested in that there a plenty of articles about this), the shortcut of the software is probably advertised, which means the windows installer checks if everything is in its place before the software is started.
if you can edit the msi, make the shortcut non advertised.
if you can't, install it with DISABLEADVTSHORTCUTS
e.g. msiexec /i myMsi.msi DISABLEADVTSHORTCUTS=1
please note that this is only a quick (and dirty) workaround,
to fix this proper you need to understand the whole windows installer advertising (also called repair or self resiliency) mechanism.
but explaining all the causes and the mechanism of the repair is far beyond this answer and there are quite some articles and posts about that on the internet (and especially on MSDN and stackoverflow)
There is a more correct answer to this, and it is NOT DISABLEADVTSHORTCUTS. You set the component id to null in the MSI file to prevent repair of that individual file. See ComponentId comments here:
http://msdn.microsoft.com/en-us/library/aa368007(v=vs.85).aspx
Edit the MSI file with Orca to delete the Componenty ID, and write an uninstall custom action to delete the file at uninstall if it's there.
In addition, that's a redundant test. Windows will restore that file for you if it's missing, so the idea that you need a test to notify that it's missing is pointless. The true test should be that Windows will restore the file if it's lost, and your app needs to do potentially nothing about the missing file.
You don't mention what tool you are using to make your MSI but I'm going to go out on a limb and guess Visual Studio Deployment Projects (.VDRPOJ).
One of the (many) horrible things about this tool was that it fails to expose the foundational concept of components. Instead it makes every file a key file of it's own component and hides the existence of the component from you. I say 'was' because Microsoft killed this project type in VS. There are around 50k people complaining on UserVoice to bring this tool back and I'm guessing that 49,990 of them don't know what a key path is.
Windows Installer has a concept called the component rules and each component has a keypath. The keypath teaches MSI how to handle repair scenarios. But your tool has to allow you to be able to control this to make it work.
Windows Installer is functioning exactly the way it's supposed to function. You just aren't up to speed on what that is.
However, if you want to ignore Windows Installer best practices and continue using the tool you use today, the trick is to install the app.config file as a different file. Then have the application copy the file to the real file name on run. Windows Installer won't service what it didn't install.
Several answers have been provided that can work:
You can install the file with a blank guid. Then you need to remove it on uninstall using the RemoveFile feature. You will also run into issues if you want to replace it during an upgrade. Could be tricky at times.
You can disable the advertised shortcut(s), but this affects too much in my opinion.
Finally you can use my suggestion to install a separate non-advertised shortcut to use to launch the application. Such a shortcut bypasses the self-repair check. It may still be invoked by other means such as missing file associations, COM registration or similar, but those are exception states.
However, my preference is that an application can start without a config file present, if at all possible. I always suggest a good startup routine with "internal defaults" available. The startup routine should also degrade gracefully if faced with any file system access denied conditions.
Most importantly you should place this config file in the userprofile so you can generate the file on first launch for the user in question. It can even be copied from a read-only copy in the main installation directory.
When you generate a file from internal defaults and put it in a userprofile location, the file will have no interference with Windows Installer at all. The issues that results is how to clean up user data on uninstall. I discussed this with Stefan Kruger (MSI MVP) at one point, and I agree with his notion that user data is indeed user data and should not be automatically dealt with by your installer at all. Leave it installed, and clean it up via system administrator tools if necessary - for example logon scripts.

VS setup project destroys self when installed files are deleted

This should be pretty simple, but I can't seem to get it. I have a setup project (VS2010) that packages a few dozen image files (along with my SQLite file) and copies them to the user's computer when the program is installed. As these are essentially "stock" images, it's ok if the user deletes them (there is functionality to do so from within the program.) However, after one or more of these images have been deleted, the next time the program starts it gives a "Windows installer" dialog box, and deletes all of the remaining data files!
What I think is happening is the program sees the missing files, assumes the installation has been corrupted, and tries to go into some kind of recovery/uninstall mode. I'd like to know how to indicate in the setup project that the files need to be installed, but may be removed by the user at any time.
I have tried several combinations of File properties, and nothing seems to do quite what I want, which is for my installer to put them where I say and never think about them again. Do I have to reinvent the wheel and do this through a custom action??
EDIT: Transitive and Vital had both been set to True. Setting them to False causes the program to re-add the deleted images back after it has been restarted! I'll probably go with a custom action if I don't get an answer.
When using a file association or advertised shortcut Windows Installer automatically checks if component key paths are missing. If a key path is not found, a repair is trigger to reinstall the component.
Most likely your installer repair process does something that removes the other files.
A solution is to not register your components with Windows Installer. This is done by using a null component GUID and it's not supported by Visual Studio setup projects (it is however supported by most of the other setup tools).
Another solution is to make sure that your image files are not key paths in their components. This is also not supported by Visual Studio.
If you want to use a setup authoring tool which offers more control, you can take a look at this list: http://en.wikipedia.org/wiki/List_of_installation_software

What is the path to an installed ClickOnce application?

I wrote a "Hallo world" type Windows Forms application in C# to test authentication issues. I'm going to be running the eventual application from a server periodically, so I want to be sure I can get to the resources, and fix that before committing to the whole application.
So, in Visual Studio 2010, I choose Publish....
It says "Where?", and I specify a folder on a shared file system.
It says "How will your users install", and I say, "URL" or something like that.
It says "Where", and I give it a URL in the same shared file system, different folder.
All is right with the world....
Now, I install it on my server by double-clicking "setup" on the shared file system where I published the application.
Now, I find a shortcut in my start menu, all good.
Now, I want to set it up so SQL Server Agent executes it periodically (and tests authentication...) so, what is the URL I give it to execute? I've been trying everything, but not going so well. I don't understand the publish method much at all....
How can I fix this problem?
Look at the Start menu shortcut for your installed application and you'll see that it points to a "ClickOnce Application Reference" (.appref-ms) file buried deep within your user folder. You can start the application by executing that file.
Example:
Process.Start(#"C:\Users\Igby\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Microsoft\MyClickOnceApp.appref-ms");
I don't know anything about SQL Server Agent, but try giving it this path.

Bazaar (bzr) integration with Visual Studio

What's the best way to use Bazaar (bzr) as the version control system in Visual Studio 2008?
The best I found is TortoiseBZR and the command-line - nothing integrated with VS.
I wouldn't even bother with TortoiseBZR; bzr is very easy to use from the command line.
BTW: The last time I tried it, TortoiseBZR used to lock up windows explorer while it went off to a remote repository to determine the status of files, not sure if it still does this ... ? See also this SO question.
There is no native integration to Visual Studio, but there is good GUI application, called Bazaar Explorer. It's the part of official standalone installer, and also can be installed separately as bzr plugin.
Old, I know, but since this shows up on the top for Google search, the best way to integrate is a combination of Visual Studio's External Tools, and tbzrcommand.exe and bzr.exe. You can set up things like Status to go to the output window, and things like Diff to go to the tbzrcommand GUI window.
(I'm assuming you've installed TortoiseBzr here.) Using these as examples, in VS open Tools->External Tools, then Add. For the program, browse to the Bazaar directory and select bzr.exe. Name the command Status. For arguments, type "status" (sans quotes). Select that the output should be directed to the vs output window, that the command should be terminated when complete. Open a simple file under code control and add a space somewhere and save, then under external tools, choose status to verify that it shows up as a pending commit action. (You can add these to their own menu later, once they work.)
Next, add another external command and name this Diff. For the program, browse to the Bazaar directory, and choose tbzrcommand.exe. For arguments, type "--command=diff --file=$(TargetPath)" (sans quotes). Leave the options all unchecked. Then, for the file above that you added a space, select it in the solution explorer window and choose Tools->Diff. A TortoiseBzr window should appear (along with an annoying DOS window), and show differences between the working version and the latest commit version of the file.
For something like a commit, which requires a comment, you'll have to put in arguments like "commit -m " (sans quotes) and check the box to prompt for arguments (to allow the entry of a message for the commit).
There's a project in Launchpad, but it looks like it's abandoned, and when I downloaded it, I couldn't get it to build.
This is something I'm interested in myself. Tracking adds, drops and renames automatically in an IDE is the way to go. Seeing status is nice too.
If you don't need the SCC integration, just the ability to use the tool, try the setup in this article:
http://www.codeproject.com/KB/macros/Bazaar4VS.aspx
I've ported VisualHG to work with Bazaar:
https://launchpad.net/visualbzr
It's currently an alpha version, and has only been built and tested for Visual Studio 2010, but common operations should work OK.
Edit:
This plugin hasn't moved on much, but it does now support Visual Studio 2012.
Unified SCC has support for bzr. It is commercial but claims to be free for OSS projects.
UnifiedSCC
I too was trying to use this, and found that visual studio has an option of "External Tools", which can be found under the tools tool bar. Upon trial, I found that one could create a link to the bzr.exe (or any other exe tools you may want to use). Then, it asks for arguements. It is here where you can begin to use magic.
For me, to commit changes directly, I have created an arguement of commit -m "", which commits without message to the bzr branch if one exists in the working directory (to achieve this, you also have to change the starting directory to solution directory).
I also created a push command to my launchpad using similar idealogy

Resources