Nuget - Writing tools for Package Manager Console (custom cmdlets) - visual-studio

I've installed nuget package manager and I really love mvc-scaffold extension. I would like to write similar tool for my projects.
Is there any API reference or some documentation for nuget I can learn from ? TIA for any suggestions.
Edit:
Question is already 'answered' (thx one more time), here are some links that can be helpful:
http://nuget.codeplex.com/releases/view/59864 - package explorer (download + see what it's inside the package - thank God for comments in mvc scaffolding ps scripts :))
http://channel9.msdn.com/Series/mvcConf/mvcConf-2-Steve-Sanderson-MvcScaffolding - video from mvcConf2
and of course Steve Sanderson's blog : http://blog.stevensanderson.com/

I wrote the current version of MvcScaffolding that you mention in your question. Here's how it adds PowerShell cmdlets to the Package Manager Console:
Cmdlets are written in C# and compiled into a .NET assembly (see http://msdn.microsoft.com/en-us/magazine/cc163293.aspx)
The .NET assembly is included in MvcScaffolding's "tools" folder (see http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package#From_a_convention_based_working_directory)
MvcScaffolding also contains an init.ps1 file that NuGet runs each time you open a solution containing it (also described at http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package#Automatically_Running_PowerShell_Scripts_During_Package_Installation_and_Removal). This script uses the PowerShell "Import-Module" command to import the cmdlets from the .NET assembly, making them available in the console.
Note that it's not actually necessary to write your cmdlets in C# and call Import-Module. A simpler alternative is to write them in PowerShell (see http://technet.microsoft.com/en-us/magazine/ff677563.aspx) and define them inline in your NuGet package's init.ps1 file.
Or, if your question is about how to add custom scaffolders to MvcScaffolding (e.g., so you can say "Scaffold MyCustomThing -somecustomparams"), then use the command "Scaffold CustomScaffolder MyCustomThing", and then edit the PS1/T4 files that appear in your CodeTemplates/Scaffolders folder. I'll blog more details about this soon.

Related

How to determine version of iTextSharp?

I'm using VS2022, and I received an old project, where iTextSharp was used, but I can't determine a specific version of the mentioned.
I've tried - Tools -> Nuget Package Manager -> Manage Nuget Packages for Solution...
But was unable to find iTextSharp.
Thanks in advance.
It sounds like the assembly has been included directly in the source control, as was common place before nuget. Take a look in your project's references and you should be able to locate the dll. Checking the file's properties in VS should show you the assembly's details in the properties panel and should also show you which version is being used, if not the path or filename may give you a clue as to the version being used.

VisualStudio: Find implementation inside my nuget package

I have a project, that uses my own nuget package from my nuget feed. I've set up a source server in devops, so I'm able to step into the code inside this package by pressing F11.
But also I'd like to be able to jump to this code using Ctrl+F12 (go to implementation). Now when I try this, I get "The symbol has no implementations".
Is it possible?
VisualStudio: Find implementation inside my nuget package
I am afraid there is no such out-of-box way to do this at this moment.
As we know, the symbol server is used for debugging. We could step into the source code by the Debugger and symbol.
But if we use Ctrl + F12 directly from your code, it would only search for implementations in your code. It does not invoke the debug mechanism, so it can not find the implementation in the nuget package, even if we provide the symbol server.
So, if you still want to find implementation inside nuget package, as workaround, you can try to add the source code into the reference project, we could include the source code in to the content folder in the .nuspec file,like:
<files>
<file src="TestDemo.cs" target="content\Implementation" />
</files>
In this case, the source code will be added to the reference project, we could use Ctrl+F12 to find implementation.
Hope this helps.

XERCES XML parser

I am relatively new to programming and have been tasked with writing an xml parser using Xerces. My project is in c++ on Microsoft Visual Studio 2015. Are there any good examples for Xerces being used on Windows? I have looked through Apache and it is horrible and has been talked down on by all my coworkers. Most of the help I've found has been for Linux command line or overly complicated examples for specific use cases. Is there anywhere to find a simple example of xerces being used to parse a simple, known xml file? Thank you for any and all help as it is much appreciated!
The official Xerces documentation provides a lot of examples using both DOM and SAX parsing technique. You can find it here: https://xerces.apache.org/xerces-c/samples-3.html.
In order to build the examples and use them as direct references for your code, you have to follow the build instructions in https://xerces.apache.org/xerces-c/build-3.html.
For my personal requirements I created a VS 2013 solution for both Xerces library generation and samples compilation. The command to invoke for generation of the VS solution should for you be something simliar like
cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=D:\libs \path\to\xerces-c\source
where you can set the destination path of the output files via CMAKE_INSTALL_PREFIX , while \path\to\xerces-c\source should be the top level directory of the Xerces download, where the CMakeLists.txt file is located. Naturally you will need to install cmake on your Windows computer, which can be downloaded here: https://cmake.org/download/
Finally in order to start the examples, just use the generated VS solution or open a command prompt and start the desired program. For example use the "DOMPrint" application by calling .\DOMPrint.exe xxx.xml. The location of the binaries is in ${CMAKE_INSTALL_PREFIX}/bin.
Please be aware that you will have to compile or provide the Xerces .dll files to be able to start any programm related with the library. It also can be built using the generated VS solution out of cmake.
Please don't hesitate to ask further questions, if the issue is still up-to-date!

Create Language Service for VisualStudio 2010

I want to build a language service for visual studio 2010. I was first trying to follow the tutorial and documentations from MSDN.
The problem is i don't succeed to make this works (i'll explain later my problem). So i digged into existing implementations, i found Ook! and lua . both of these projects doesn't use the tutorial or documentation i found on MSDN, but something based on MEF. Lua used this only with previous Visual Studio versions.
So i'm wondering if i'm using an obsolete method to create a language service (But the documentation aims Visual Studio 2010), or there is different ways to do this, which depends on needs.
In my case, i've got a language that doesn't need to be compiled into cli, but i want to have an editor that have colorization, syntax warnings and errors, intellisense ...
The problem i mentionned is that when launching exp instance, there is no text editor with my file extension, and visual studio begins to have many lags. The language service is registered using 3 attributes : ProvideServiceAttribute, ProvideLanguageServiceAttribute and ProvideLanguageServiceExtension. Also initialized in Package intialize method, like mentionned in Proffer the Language.... The package is loaded when i try to open the file with my extension, the language service is initialized.
So i don't get it why i does not work, could you please help me to understand how language service works, and what is the best way to implement it
Thanks
Good chance your IScanner implementation has an endless loop, happened to me.

LinqBridge Breaks Razor Views: .NET Version-Based File Output Restriction

Our project uses several NuGet packages, a few of which reference LinqBridge, a library that re-implements LINQ to Objects for C# 2.0. The LinqBridge.dll file lives under /packages/PackageName/lib/20/LinqBridge.dll, so it clearly is supposed to only apply to .NET 2.0.
The problem is that, even though every project in the solution is configured to build to .NET 4.0, the LinqBridge.dll binary gets copied over to the final /bin directory and wreaks havoc in Razor views. If I perform .Select() on an IEnumerable, there is an ambiguous call between the built-in LINQ call and the re-implemented one that LinqBridge provides.
I clearly do not need the re-implemented version; if I simply delete LinqBridge.dll from the output /bin directory, everything works just fine. However, that is not an acceptable permanent solution.
Is there any way I can configure something to quit copying that file, which is for an old .NET version, into the /bin output?
Edit: I duct-taped together a solution by adding this to the "Post-build event command line:" commands under "Build Events" in my solution properties:
del $(SolutionDir)\bin\LinqBridge.dll
It's still far from ideal, but at least it lets my project run for now.
NuGet has support for different binaries for different .NET versions so I would suggest that the packages you are using are built badly.
I would contact the authors of the packages and see if they can fix them so that only the net11 or net20 versions include LinqBridge.
Supporting Multiple .NET Framework Versions and Profiles
Many libraries target a specific version of the .NET Framework. For example, you might have one version of your library that's specific to Silverlight, and another version of the same library that takes advantage of .NET Framework 4 features. You do not need to create separate packages for each of these versions. NuGet supports putting multiple versions of the same library in a single package keeping them in separate folders within the package.
(more...)
A useful approach we found was using the LinqBridge.Embedded Nuget package instead of the standard LinqBridge package. This embeds Linqbridge as a C# file within your project, and hence does not get copied over to the bin folder and loaded into the context of the Razor view.
This was useful to us because an assembly we reference still needs to be built in .Net 2.0, as it is also referenced by a 2.0 application. Hence that assembly uses LinqBridge.Embedded, and the LinqBridge assembly does not end up in our 4.0 servers' bin folders.

Resources