I have several reusable parts of my code in a .ttinclude file. I would like to make a reusable / installable visual studio add in (something like a VSIX) to deploy this file and then be able to include it in any t4 template in any project, just as if it were an assembly reference (something like being able to install the .ttinclude file to the GAC).
I already googled about it but I couldn't even find a tip on how to start doing this.
Any help is appreciated.
You can for instance use NuGet, NuGet is shipped with Visual Studio and is a pretty decent. For inspiration take a look at: https://github.com/mrange/T4Include/tree/master/NonSource/NuGet
The .nuspec file is used by NuGet to build a package and it deploys 3 ttinclude files and a sample tt file.
Hope this can help you get started.
Related
I have been working on a class library that generates c# projects from an existing c# project. Right now I have the template project in a specific folder on my machine but what I really need is to add that template project to the class library as a resource, so I could distribute the dll. Any suggestion will be very helpful.
If I'm understanding this correctly, and you're saying you've got a project that produces new C# projects (so .csproj and .cs files) and you want to add those as a resource, then I'd zip them up and add the zip as a resource.
Also have a look at the way new templates in Visual Studio are distributed. Within Visual Studios program files you'll find the built-in templates for example "C# Console Application" and "VB.NET WinForms" in the default path "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ProjectTemplates", however you can always download new ones from online and add them to Visual Studio, I'm guessing they could be zip or some form of packaged file.
There's information from Microsoft on how to create your own project templates and mentions about zipping them up https://learn.microsoft.com/en-us/visualstudio/ide/how-to-create-project-templates?view=vs-2017
There's also a guide here on how to create your own project templates https://www.ecanarys.com/Blogs/ArticleID/180/Create-custom-project-templates-in-Visual-Studio
Having a look around at distributed project templates, they mostly come from the Visual Studio Marketplace.
Video 18 of this series on the Microsoft Virtual Academy might help you.
Creating and Adding References to Assemblies
https://mva.microsoft.com/en-US/training-courses/c-fundamentals-for-absolute-beginners-16169?l=Ry6jz0QIC_5706218949
I have a VS2017 solution and project which is displaying these core dll libraries in solution explorer, which pollutes the view.
The dlls are included via a .targets file included in a 3rd party nuget package.
I know this because when I try right click item -> remove, I get error prompt:
Cannot modify an evaluated object originating in an imported file
"....nuget\packages\some.third.party.package\1.0.0\some.third.party.package.targets"
Obviously, best thing to do would be to solve root problem and not include these dlls files in msbuild targets file, however let's assume I cannot remove/modify/update this 3rd party library and it is necessary to use.
How can I configure Visual Studio (2017) to not show these dlls? Some way to filter the view is a good enough fix for me.
How can I configure Visual Studio (2017) to not show these dlls? Some way to filter the view is a good enough fix for me.
To my knowledge, there is no such configure Visual Studio (2017) to hide those dlls. Because those files are included via a .targets file included in a 3rd party nuget package, we could not handle those dll files directly. In addition, you also have no control over this third party package.
So I am afraid you could not hide those dll files in Visual Studio 2017 without manipulating dlls files directly.
I am making an installer using NSIS and my gameplan was to
Build the startup project
Copy the Files created from the bin/(x86) or bin/x64 folder and embed them in the installer
The problem is that some files do not get included. From what I have seen, these files are exclusively Microsoft dlls. Does anyone have any ideas on how I can include them?
My idea is to parse through the csProj file and loop through every file on the Item-Group -> PublishFile node, check if it is in the bin subfolder, if it is not,embed the file in the installer.
Is there a simpler/better way to do this? If not, is there atleast a class(perhaps a DTE class) that represents the contents of the csProj file so I wouldn't need to parse xml? I have looked around and I couldn't find any.
From your original post what I can understand is that, you are building some sort of C# application and want to build a installer for the same.
Now why do you need to pack Microsoft Dlls?
Microsoft do provide every redistributable packages to be installed on end-user computer. You need to analyze what are the packages you need when running your application on a computer that doesn't have Visual Studio installed.
I think you only need .Net Framework and SQL redist packages. And these things can be installed silent during installation. And this is the proer approach.
I would like to use log4j.net in my windows forms project. However I have never used any library or dll in .NET. How to do it? I look at the site, but I can't find it.
I'm using visual studio 2010.
Add the log4net assembly to your project:
Browse to the log4net downloads page and download the latest log4net archive
(right now the latest version is 1.2.10).
Extract that archive and place the files somewhere to your project
(for example in a folder like yourproject/lib/log4net).
In Visual Studio right click in your project on the References folder and click on Add Reference....
Browse to the folder where your assemblies are (see point 3) and choose the log4net.dll assembly.
Here are some nice basic tutorial for the first steps using Log4Net:
Log4Net Tutorial pt 1: Getting Started
Using Log4Net in 4 Simple Steps
Log error or exception using Log4Net
In your project, you need add a reference to the library, usually by selecting the DLL from the references dialog.
A package manager, NuGet, has been created as an add on to Visual Studio 2010, which lets you select libraries - it will download and set them up for you.
Whichever way you do this, you will now be able to use the library - in a code file, use the using directive to import the namespace, then you can use the classes and other public members of the library in your code (though you could use the fully qualified name every time, if you wish to).
This has nothing to do with a library being open source or not, by the way.
you can easily get now using NuGet package manager in visual studio 2010
Write this command in Package manager console.
Install-Package log4net
See this link
Do you have any specific problems?
Check link below and maybe ask a question if you are stuck on something:
http://sadi02.wordpress.com/2008/06/29/log4net-tutorial-in-c-net-how-can-i-show-log-in-a-file/
Hey everyone, I'm currently having difficulty adding the latest taglib-sharp solution to my current solution which contains my vb.net console project on Visual Studios 2010. Essentially I want to code everything necessary in vb and use taglib-sharp to extract all tags needed from an mp3 file. Unfortunately, when I include the solution of taglib-sharp and perform the necessary conversion visual studios 2008 to 2010, I receive an error stating "Failed to backup file as C:\temp\taglib-sharp-2.0.3.7-windows\taglib-sharp-2.0.3.7-windows\Backup1\taglib-sharp.snk". I made an attempt to build the solution with no luck. How do I resolve this?
To be quite frank I'm not sure if I need to open the solution if I just want to use the libraries for my vb program. Do I need the solution in order to use for instance "TagLib.File"?
In case you're wondering, I downloaded this library from http://download.banshee.fm/taglib-sharp/2.0.3.7/
I would recommend installing taglib-sharp with NuGet. NuGet is the best and easiest way to use opensource libraries in Visual Studio. You dont have to compile anything, and you don't need to think about projects and solutionfiles.
To install TagLib#, run the following command in the Package Manager Console in Visual Studio.
PM> Install-Package taglib
The NuGet distribution of taglib-sharp can be found at http://nuget.org/packages/taglib. The official source code repository is at https://github.com/mono/taglib-sharp.
Either ignore the backup, or open TagLibSharp in 2008, compile the DLL and then reference it in your 2010 project if you only need to use the libraries.