I'm building a web app project and want to reference a few dlls from a desktop c# project. Both projects are pretty big.
This has all grown organically, so what we've done so far is include the dll projects in the web app solution which makes it easy for debugging. So at the moment all our code (desktop apps and web apps) sit in one big git repo and we build the web app and copy the code to a web server via Jenkins.
The time has come to manage the code better and split the repo into two. The problem I'm having is that I can't build the code anymore as is via Jenkins as the desktop app code (and dlls) will be gone from the Jenkins working directory (unless I create a common working directory).
I just want to get some ideas how to best manage the code:
- How do I best include the desktop c# dlls in my web app solution?
- Is there any way to still being able to debug the dlls if I don't include the dll projects in the web app (when debugging the web app)?
- How do I keep the dlls in the web app solution up to date (say if I put them into the bin folder)?
- Is there a way to not include the dlls in the repo, but have Jenkins rebuild and copy the dlls?
You can host your shared DLLs in a nuget package in its binary format and have it referenced by both the desktop and the web application.
I don't know about the Jenkins part, but a quick google said that there is a plugin that support nuget.
Creating nuget packages is an easy and straight forward process with adding some meta data about the nuget in a nuspec file and calling nuget.exe with some parameters to create the package (nupkg) for you, that you can later reference in your project.
Hosting nuget packages to be found and used later, you will need to create a feed. it can be as simple as storing files in a folder somewhere and configuring your build tools (visual studio, MSBUILD, etc.) where to look to find nuget feeds.
referencing a nuget is done in visual studio via nuget package manager plugin.
Related
I've just finished my Windows Forms App project in Visual Studio using C#. I know I need to release it. To do so I need to go from Debug mode to Release above in VS and then just click on F6. After that I have a folder with an exe file in it. But in my project I use a dll library which was copied on my PC and registered by regsvr32.exe in cmd. Next in VS I went to Solution Explorer and added the library in References by writing the path to it. I also use two packages which were installed by NuGet Package Manager.
My program is developed to use it by my coworkers so I have to distribute it to them. The problem is that I don't know how to prepare my app for it.
I'm reading lots of different articles about the release step but I'm getting more confused. People usually write that I can just copy the exe file in the release folder and use it in another PC after installing .Net there. But in my project there are also the three libraries and without them my program won't work in another PC. I can copy and register the first library on other computers but what about the last two? How to set up them correctly?
About the first library, I put it in a folder created by me manually in the C directory of my computer. The release folder is in another place. And when registering this library in cmd and then adding it to References, I specified the path to it. It means if the path has been changed, it won't be possible to use the library in the project. I tried some times. It's not convenient and when placing the app in another PC without VS where I can specify the path, my program won't probably work. So it would be very convenient to place this library next to the release folder and after putting it in another PC, the path to the library wouldn't cause any problems.
To sum up, I'm looking for the way to easily and conveniently distribute my program to users. Of course, I want to put my app and the libraries together in a PC, not to set up them separately and then tune them separately to make the program work there. Might there a way to release it as an app with all the libraries connected to it?
I feel it must be easy but I'm not so experienced. I'm sorry for that.
It is recommended that you use ClickOnce deployment:
ClickOnce deployment is a Microsoft technology that allows you to easily deploy your Windows Forms App along with all its dependencies. With ClickOnce deployment, you can publish your application to a web server or a file share and users can install it by simply clicking on a link. ClickOnce will automatically download and install all the required DLLs and packages on the user's computer.
Of course, there are some third-party packaging software that I can't recommend. If ClickOnce doesn't help you, I'll think of other ways.
I am currently working on a personal project but I want to use Azure & Visual studio online build facilities for self teaching purpose. I am having a hard time resolving this problem :
I have a wpf app connected to an azure web api.
Wpf app is in its own Git repo, web api is also in its own Git repo.
Since both apps shared a common model, I put common model in its own repo as well to avoid code duplication.
I must be missing something ....
What I want to do
When I build on Visual studio online, I want to build "common" and feed its output dlls to webapi and wpf apps so that they can reference the model.
Solutions considered so far
nuget package
making a nuget package of "model" but where do I push it ? It's definitively not going to be of any value to nuget.org so no go.
I would need some private nuget repo in visual studio online, not sure it exists.
postbuild event
I also considered adding a post build event to the "common" build and copy its bin*.dll output to wpf and webapi apps to some "dependencies folder" but I find this dirty, Moreover I am not sure a build can push its output to the input of another build (I know Jenkins can but I am unsure about visual studio online), Moreover, how can I reference dlls which do not exist yet in my csprj ?
commit bins in repo (ugh)
Of course, I could build model locally and push the resulting dll in the git repos but, well, I am against putting binaries in versioning tools :)
Change my design
Consider that WPF only needs dto and not the real entities (which is true) but webapi will need to deserialize dtos anyway so back to square one, but with dtos this time :)
Thanks for your input !
Thanks a lot to CrowCoder !
That's exactly what I needed : using the "Package Management" extension in visual studio online, which is free up to 5 users.
Steps required :
configure nuget on my local machine,
create the nuspec,
create the feed,
package the model library
configure the build to push the library to the feed
use nuget packages to reference model
I'm creating a package for NuGet from a library that wraps a console application. How would I supply this console program with the library I am creating? The console .exe needs to be in the same directory as the library after the build, but not required during build.
I don't believe I can place it in the "lib" folder as it's not something that the referencing program can actually reference in the first place, and not the "content" folder either since it's needed after the build process, not during.
Am I forced to have to get the user to download the console application separately and supply the filename to the library? Or is there a way that I can easily implement this need in NuGet?
Nuget packages are not meant for deploying executables. The purpose of Nuget is to simplify the deployment of other libraries that you need to include as a reference in your coding projects. Also I'm not sure what you mean by console application but if this some actual 3rd party console program and not the command prompt in Windows and this meant to go to an end user who just needs to double click and run the application then you either need to create an installer with InstallShield or one of the installers provided with VS. Additionally you could look into chocolatey which is meant for application distribution and deployment.
Chocolatey
I have two ASP.NET web projects and they share a lot of images and JavaScript files. I tried to create a shared project and linking it into both ASP.NET csproj files:
<Import Project="..\Shared\Shared.projitems" Label="Shared" />
But images inside the shared project are not found during debugging with IIS (Browsers "image not found" image is displayed). But Visual Studio recognized them and showing the image files in IntelliSense.
Any ideas?
You still can bundle resources with project and distribute it, but you nee to create nuget package.
create project
make nuget package
publish it to private feed (e.g. myget.org)
add reference to your feed from client projects
PS: Only content of folder 'Content' included in nuget package.
Apologies for the speculative answer, but hopefully this will help someone;
This is a struggle I'm currently facing too (which is concerning, as nearly two years have passed with barely a mention).
I have also had to manually add the Import line to each solution as it appears you have.
I think the issue is with the inbuilt debugger not knowing how to serve the files properly. If you deploy the compiled solution to any instance of IIS it appears to work correctly.
I am experimenting with the inbuilt debugger to see if I can get it to work, but am quite confident I'll have to use a local IIS instance moving forward.
Shared projects provide invaluable functionality, so it's a shame it's still not natively supported.
At the end of the day your images have to actually be somewhere, you can't just reference them from another project. It would work if this other project was hosted in IIS, given a domain, and you referenced the images from this domain. Perhaps call it your CDN.
When you reference a project to get at classes etc, the project is bundled up in to a dll and packaged along with the main project. Images, js files etc can't be bundled in to a dll, and will not be copied across to your project.
I have a .net solution with 2 projects:
The app
The installation project
The installer is set up in order to copy various additional assets into the project folder for use in the app during runtime (they cannot be embedded resources).
VS 2010 gives us the great capability to publish and app with the ability to use AutoUpdate for free, however I can't work out if I can use the same option when generating the installer through the installation project.
Does anyone know how?