How to create a Project Template without requiring PacMan (or refresh)? - c#

If you create a new Windows UWP project in VIsual Studio 2015 using the out-of-the-box Blank template you will find that intellisense works without having to build or refresh the project.
Now, create a custom project template based on the Blank template. You will find that your new project template creates a project fine. However, that new project does not have intellisense until PacMan (the Nuget package manager) fetches Microsoft.NETCore.UniversalWindowsPlatform from the package cache.
After you invoke PacMan and fetch Microsoft.NETCore.UniversalWindowsPlatform, your new project will still not have intellisense. That is, until you refresh your project in Solution Explorer. At that point, you are in business.
My question. What is the setting in the VsTemplate.xml that enables a custom project template to create a project and immediately work? That is to say, what can tell Visual Studio to go ahead and run PacMan and refresh the project?
There is one requirement to this scenario. It is important that this custom template not have a custom project wizard. That is not a viable solution to this problem. I believe this can be solved with configuration, not code.
Please note, this question involves NuGet v3, not 2 or 1.
Does anyone know?

Related

How to link a library package of C# in Visual Studio 2022 so that I can use it every time in any solution or project?

I have some libraries like Colorful.Console from GitHub, I used to use it frequently. Every time I started a new project, I have to install this library de novo. How can I install it so that it became available every time?
Use the NuGet package for it
Go to Tools >> NuGet Package Manager >> Manage Packages for Solution
Click on the "Browse Tab"
Type in "Colorful" and the package will appear
Add it to the projects you need.
You'll find NuGet packages for many of the things on GitHub. That's the best way to re-use them.
Option 1
Create a new console project, add the desired NuGet package(s). Next export the project as a project template. Make sure to provide a meaningful name for each template. Here are some example templates.
Option 2
Open a project up with the desired NuGet package(s) installed, in solution explorer double click the project node, select the ItemGroup with the package. Drag it to the IDE toolbox then optionally right click on the new item and give it a meaningful name.
To use it in a new project, open the project file as done above and drag the code from the toolbox into the project file, save it then Visual Studio will download the package.
Which is better? it dependents on what suits you, I always use exported project templates and sometimes use the toolbox method along with Resharper which allows creating of snippets that can be used in project files similar to option 2 but not stored in the toolbox.

Build class library doesnt update reference in Visual Studio

Visual Studio 2019 CE with all updates as of today.
I create a Blank Solution.
Add Empty web project to the blank solution.
Add a class library.
Reference the library in my web project.
I build the Solution and can tell the library is working as intended.
I make a small change to the class library and build the Class Library only. The change i made doesnt reflect the output im expecting. If i rebuild the entire solution then the change i made does take affect.
Normally i can just build the single library and that does the trick. I cant work out why the entire solution needs to be built in order for the changes to come across to the web project? I even deleted the CL and added a new one but the same occurs - am i missing a setting somewhere?

How to Configure the nuget.config file for xamarin project is VS2015

I am building a Xamarin app in Visual Studio, but am having problems with the source control, which I think is because I don't have a nuget.config file.
Firstly, do I need one per solution or one for the whole project, or alternatively just on in the PCL etc.
Secondly (the main question), is it possible auto-generate these files based on the nugets you currently have installed? Also, when these are updated, is it possible to keep the nuget.config file up to date?
Update:
In Visual Studio the Manage NuGet packages for Solution option which was present in past versions is not displayed for my project, not sure if this is the software version or the projects configuration.

No WPF User Control Library Template found in VS 2013

I am using VS 2013 (Express Version) and I want to create a WPF user Control Library project. But I am not able to find the template in my installed templates list. If I use Winforms, I am able to build a DLL out of my Winforms Application Project just by changing the Output type as "Class Library". But it is not happening in WPF and it is throwing errors if I do so. Is this the correct method of doing it or am I going wrong?
And in the Create New Project dialogue window, I am not able to find the .NET Framework selector drop down. After creating the project only I am able to change the .NET framework version by going inside the properties of the project.
Kindly help me to get out of this. Thanks in advance.
I have been working on this exact same problem for hours this morning. Here is what I think I have learned:
With Visual Studio Express 2013, it is by design that the WPF User Control Library template is not available for making a New Project. This is because it is the free Express version.
With the Express version, you don't have a "devenv.exe" for trying the "devenv /installvstemplates" to "fix" things. It is, instead, called (just a moment while I look this up again...) "WDExpress.exe" and will be located (if you have default location) in the "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE" directory. BUT - this won't help you. It won't fix your problem, because, as I mentioned, your Express installation is designed to not have that template available for New Project, so your "fix" won't put it there. I know this because this is what I tried myself. (Also, note that the instructions for doing this tell you to uninstall any extensions you've installed before doing it. And then, of course, if you still want them you have to reinstall them. Like I still have to do, incidentally.) I'm letting you know all of this so you don't go through the headache I'm having.
Note that I have not done this yet, so this is somewhat hypothetical on my part, but is based on my research on the Internet so far - Your solution is to create a WPF User Control Library manually [but now see UPDATE below]. (No, I don't know how to do this yet. I got into this in the first place, because I'm a WPF novice - just started working with it a few days ago - and late last night I got this great idea to add a "spinner" progress indicator to my "WPF play/learning project" I'm working on, and found a couple of relatively easy-to-work-with samples on the Internet - both of them are a WPF User Control Library - and at first I wanted to use the copy-and-paste to put the code in. But then I discovered... well, our mutual problem, because I'm using Visual Studio Express 2013. No such template under New Project. And literally at the tail end of my about-to-throw-in-the-towel, I'm googling and your post, Dhivakar, is already showing up with the right Google search.) So I haven't finished my research yet, but my next step is to learn exactly how to create a WPF User Control Library manually (the code and various project property settings), and then I can just save a WPF User Control Library skeleton for future use and document the details.
UPDATE: This guy totally has the solution for Express versions. I have followed his steps and it works great. The only additional piece of information I would add is that in my version (VSE2013), after you've created your WPF User Control Library template, when you open Visual Studio again and use File -> New Project, my selection in the tree (for a Windows app) came up under Templates -> Visual C# -> Windows (which is what I've been using). I did not see my template showing up there, after I created it, and I thought, "Great! Another piece of advice that doesn't work." But then I clicked up one on the "Visual C#" parent - and there was the template!
Here you go:
How to add a WPF control library template to Visual C# Express 2008
https://dotupdate.wordpress.com/2007/12/05/how-to-add-a-wpf-control-library-template-to-visual-c-express-2008/
Yes, it works this way for VSE2013 too.
UPDATE 2: I'm not absolutely positive about this, but I think he missed one little piece. In his step #4 he says to delete Window1.xaml and App.xaml. Maybe this didn't apply with VSE 2008, but in VSE 2013 there is also the App.config file which I believe is extraneous for our purpose. So you can delete App.config as well. As I said, I'm not absolutely certain about this yet, but I noticed that file in the project when I added a WPF User Control Library project to my solution, and I deleted it, and the solution compiled okay.
Try running devenv with the /installvstemplates switch, from https://msdn.microsoft.com/en-us/library/vstudio/ms247116(v=vs.100).aspx
If this doesn't work, browse to C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ItemTemplatesCache\CSharp\WPF\1033\WPFUserControl (this could change dependent upon your installation directory), open the .vstemplate file in a text editor, and make sure the setting is set to true, then try running devenv with the switch again.
Hope it helps.

Setup project with autoupdate feature vs2010

I have created a setup project in visual studio. It works fine, now when i make some changes, create new setup file and then try to execute it. It gives me this error.
I don't want user to bother with this step. I want it to update the application or uninstall it first and then install new version.
How could i do this.
Kindly guide.
Windows Installer automatically uninstalls the old version if you increase your package ProductVersion and change the ProductCode. This can be done in the project Properties pane.
If you don't do this, you need to uninstall your old package manually using the Control Panel applet.

Categories