Unable to create a nuget package out of a custom control in xamarin forms - xaml

I just created a simple custom control in my xamarin.forms project and want to use the same control as a nuget package in my other projects. After creating the .nupkg file I tested it by adding as a local package in another xamarin forms project.The issue is the package I created is installed,but the contents inside it are not available.. Can anyone help me on resolving this..

You have to tell visual studio to pack the content of a library and generate a nuget package. This will then include the dll in the package and allow you to access it from other projects.
You can see how to do this in Visual Studio here
Including Xaml files is trickier, but if you can do the UI in code it easier enough. I created Xamarin.Forms control library on github that might be a good place to start.

Related

VS 2019 Custom ASP.NET Core project templates

I'm trying to figure out how (or even if) I can create a custom Visual Studio project template that hooks into the existing ASP.NET Core Web Application template available in Visual Studio 2019?
What I want to do is something similar to madskristensens ASP.NET Core Template Pack (GitHub source code). However instead of VS 2017 I want to do this for VS 2019's revamped "New Project Dialog" window. So imagine adding an additional ASP.NET Core web application template in the place highlighted below.
I am able to create new project templates (both for Visual Studio and for dotnet new) but nothing has worked thus far. Has anyone been able to extend VS 2019 in this way, or was this taken away after VS 2017?
After doing some more investigation between both VS 2017 and 2019 (Community) I was able to successfully figure this out! Man oh man do we need some docs on this because this felt like a doozy!
I was able to use the ASP.NET Core Template pack as a building block for putting something together. For those who don't know, the extensions are designed to add templates to Visual Studio using .nupkg file(s) embedded in the extension. The use of the .nupkg files is similar to how dotnet new works with custom templates. I've got a working prototype on GitHub that supports both Visual Studio 2017 and 2019.
Now if you're like me, you may look at either madskristensens or my project and ask "How in the heck does this work!?" Great question! Here are the details I have the time to fill out right now:
Build out a custom template (or templates) and place them into *.nupkg file(s)
In my sample, my SampleTemplates project contains three different project templates. I generate the .nupkg with dotnet pack
A vs-2017.3.host.json file is required in the .template.config/ folder so that the ASP.NET Web Application wizard can display the template.
At least 1 or more other requirements need to be fulfilled to be displayed in the ASP.NET Web Application wizard, but I haven't yet figured those out, as adding the file to a console app template doesn't cause it to appear. I want to try and figure this out, although I'd love help if anyone already knows!
The template.json needs a Framework symbol to define the list of .NET Core framework targets that are supported by the template.
In doing some testing, it didn't look like the Framework symbol didn't substitute into the .csproj, so that is why my example also includes a TargetFrameworkOverride symbol that the Framework symbol replaces.
Place the .nupkg file(s) into the root of a VSIX extension project and make sure to set the "Include in VSIX" flag to True. I emphasize root because originally I had the NuGet package landing in a build\ folder in my extension and my templates weren't being picked up.
I'll try to put together a README in my example project to provide a better outline of all of the details required to accomplish this. Fingers crossed this helps someone out (or at least help me out in the future when I inevitably forget how I accomplished this)!
Update
As of September 2nd, 2020, the Visual Studio team released an experimental feature to include dotnet new templates within Visual Studio. I have done some exceptionally minimal testing with it, and it does appear to work, but it's not perfect. For example, I created a dotnet new template that scaffolds multiple .csproj files and .sln file, and the output didn't quite match my solution.
This is the Visual Studio blog post describing the announcement: https://devblogs.microsoft.com/dotnet/net-cli-templates-in-visual-studio/

Xamarin Forms code sharing

I'm working on a xamarin forms (PCL) project (A basic customer care chat app which is meant to run on Android and iOS only) that has just two xaml pages, custom renderers and few dependencies. This project is meant to be implemented into another existing project (which I don't have access to its source code) such that an action would be binded to a button on the existing app to show a page on my own project.
There is need for me to share my chat project with my client's developer but without exposing my source codes, perhaps compiling to dll or nuget package that would be added to the existing project to access my project's functions and pages. I have searched through the xamarin forum and here on stackoverflow but can't seem to lay my hands on a solution.
Is this possible at all? If yes, what am I missing? If no, is there any better option to use?
Please do note that the chat app completely done, so I'm hoping perhaps there's a way I could directly convert the project to a Nuget package.
Thanks in anticipation!
If the host application is a Xamarin Forms one:
-Move your cross platform shared code into a PCL or .Net Standard (ContentPages, ContentViews, Classes).
-Move your Renderers and platform specific code to Android and iOs Class Libraries.
Your client will have to reference your first assembly (dll) in their XF assembly in order to instantiate/manipulate your views/classes and platform specifics one on their Back-end side (taking into account your renderers, effects, etc ...)
A lot of Xamarin Controls Libraries Open Source hosted on Github are working like that. For example this one: https://github.com/jamesmontemagno/Xamarin.Forms-PullToRefreshLayout
If the host application is a native application, take a look into Xamarin forms embedding
Finally, I seem to solve the problem by enabling visual studio to build Nuget packages for the chat app project (summing up to 3 nuget packages) on project build.
Thanks #Rudy Spano and #Micah Switzer for your contributions

Reference from assembly to DLL in Visual Studio solution

Say, that we have .NET application App along with additional assembly ClassLibrary, which, in turn, uses native DLL called Library. All these are in single solution, so I may set up the dependencies etc.
The catch is, that I want the Library to be automatically "attached" to ClassLibrary, such that when my App references it, Visual Studio will automatically copy the Library to target bin folder.
Usually I did that by using pre-build or post-build events and adding custom scripts. But hey, all these are in the same solution. Is there simpler way to keep such native-dll-reference for .NET assembly?
You have to add the native library to your project. If the native library is in the Solution (not in the project) than it is there only for your reference. You have to add the native library to the Project because the project file describe the build behaviour.
Than add native assembly to the ClassLibrary project and then in properties set: Copy To Output Directory to Copy if newer or Copy always.

How we Integrated Libgit2 library in Visual Studion 2010 Windows Application

I downloaded two DLLs (libgit2sharp.dll and git2.dll) from this site.
After that I successfully added Libgit2sharp.dll by add reference in my .NET Windows application. Now when I add git2.dll by add reference in my .NET Windows Application, it gives an error:
a reference to 'C:\User\nitesh\git2.dll' could not be added please make sure that the file is accessible and that it is a valid assembly or COM component
Can anyone please help me understand the problem?
I downloaded two DLLs (libgit2sharp.dll and git2.dll) from this site.
First off, this is not a distribution channel that the libgit2/libgit2sharp team has anything to do with.
Install as a NuGet package:
Official releases are available as a NuGet package if you prefer to download pre-built sources. See this post which explains how to install the NuGet Package Manager in Visual Studio.
This is the easiest way to make LibGit2Sharp available to your project.
Build from the source code:
You can download the source code and build the C# code into LibGit2Sharp.dll from https://github.com/libgit2/libgit2sharp, which includes the pre-built version of git2.dll which works for the particular version of the C# code.
Easiest way to build the assembly is by launching the build.libgit2sharp.cmd. This will create a Build folder into which you'll find the LibGit2Sharp.dll and a NativeBinaries folder with the native binaries.
Now when I add git2.dll by add reference in my .NET Windows Application, it gives an error
As for the error message, it sounds like you're trying to add the git2.dll to the project as though it were a CLR/.NET assembly. It is however built from C and isn't something VS is going to do anything useful with. You do not need to add it to your project.
It does need to be available for libgit2sharp to load. The following graph depicts the folder hierarchy that libgit2sharp expects
NativeBinaries+
|___amd64+
|___git2-{shortsha}.dll
|___git2-{shortsha}.pdb
|_____x86+
|___git2-{shortsha}.dll
|___git2-{shortsha}.pdb
Note: This folder structure will be dynamically created in your project output folder if you installed LibGit2Sharp as a NuGet package. However, if you built the project from the source code, you'll have to copy this folder structure as part of your project build process yourself.

How can I make Distribution files using Visual Studio 2008

I want to distribute the installer package to my clients. Please anybody provide me details information about how can I make setup.exe file for my visual studio 2008 projects. If I am failed to provide any necessary info please let me know. Thanks in advance.
Though this is written for C#, the tutorial should work fine in VB.NET as well, if that's what you're using.
http://www.dreamincode.net/forums/showtopic58021.htm
In VS2008, add a new project. Then click "Other Project Types" and Setup and Deployment underneath that. You can then pick "Setup Wizard" this will guide you through creating a setup.exe and an MSI installer. This can then be built just like any other project, so when you make a change to your project, you can rebuild the setup.
In order to create an installer package, do the following:
Go to File -> Add New Project
Select Setup Project from "Setup and Deployment Projects"
From here you can add your files and when you compile it will generate an MSI file.
If you have access to a web server, i would publish your file using clickonce. This way anytime you make a change your users will automatically get the updates. To do so, right click the main project that you want to expose and click on the publish tab.