ASP.NET Web Application (w/ ascx WebUserControl) as NuGet Package - c#

I'm rather familiar with creating NuGet packages for class libraries. Yesterday i tested doing the same for a ASP.NET Web Application, and to my surprise it worked (kind of - with some quirks).
My Web Application is simple and only contains a single .ascx WebUserControl. My hope was that at the end i would have a DLL containing my control similar to if you were to publish the site and extract the results DLL for the control from the bin of the published site. However this is not quite what happens.
After packing the NuGet package and then using it in other projects, doing so results in the .ascx files fully being "copied" to the project with the NuGet package installed. This .ascx files from the NuGet package can be edited as a normal .ascx file would allow and still references code behind that doesn't exist in the solution.
So there are some issues. My question is - does anyone know of a procedure i can follow that would compile a user control into a DLL that can then be distributed via a NuGet package?

does anyone know of a procedure i can follow that would comile a user control into a DLL that can then be distributed via a NuGet package?
You can convert your usercontrols into custom control, here is a detail document about how to do it.
Turning an ascx user control into a redistributable custom control
The basic steps to make this happen are as follows:
Write your User Control as you normally would, typically using the Visual Studio designer.
Test it using a simple page before trying to deploy it.
Deploy the app to precompile it.
Grab the user control’s assembly produced by the deployment step, and you’re essentially done: you have your Custom Control.
Finally, use your Custom Control in other apps the same way as you always use Custom Control’s.
After compile the user control into a DLL, distributed it via a NuGet package should be easy for you.
Hope this can give you some help.

Related

Visual Studio 2019 - Cannot add Custom Pipeline Object to Toolbox SSIS

All I'm trying to accomplish right now is get my custom component to show up in the SSIS Toolbox. I've been looking everywhere I can think of for any information about creating a custom Data Flow Component in Visual Studio 2019. I have found plenty of out-dated examples and solved problems, none of which help me solve my problem.
Based on Microsoft's description of how to do this, you would think all you have to do is follow their instructions and it'll work. Not so, at least not for me yet.
Here's what I've done so far in an attempt to simplify and get anything to work:
I Created a class library and referenced the following assemblies:
Microsoft.SqlServer.DTSPipelineWrap
Microsoft.SQLServer.DTSRuntimeWrap
Microsoft.SQLServer.ManagedDTS
Microsoft.SqlServer.PiplineHost
Inherited from PipelineComponent and added the DtsPipelineComponent attribute.
Overridden methods (code below)
Signed the assembly
Created Post-build events to install into the GAC and copied the assembly to the C:\Program Files\Microsoft SQL Server\130\DTS\PipelineComponents folder.
In an SSIS project, I do a refresh on SSIS Toolbox and my component does not show up. I've tried Browsing to the assembly by going to Tools >> Choose Toolbox Items and selecting the assembly.
I get this message:
Here is my simplified code that does nothing: Sorry about having posted it using an image, but using the recommended code highlighters don't work for me either.
Here is a screenshot of the GAC listing:
I must be missing something.
Any help or ideas would be greatly appreciated. If I can't get this to work, I'll have to punt and resort to a Script Component transformation. Really hate to do that as that means each developer will have to maintain a lot of extra code.
Thank you in advance.
Hazy recollection but I'll give it a go.
The installation to the GAC means that when the package runs, the execution engine will be able to find the required assemblies and do the code instructions.
Design-time needs the assemblies elsewhere because...reasons. With 2005/2008, you had to manually add items to the "SSIS Toolbox." You are attempting to add items to the "Toolbox" which is a confusingly similar name but it's not SSIS. SSIS Toolbox is populated only when a package is opened and the project type is SSIS.
Visual Studio now automagically picks up components but either way, the assemblies need to be sitting in the targeted version Microsoft SQL Server XXX DTS assembly-domain folder.
Assume I build a dataflow component with bindings for SQL Server 2017. I would therefore install to
C:\Program Files\Microsoft SQL Server\140\DTS\PipelineComponents
If you built a custom task, it'd go to
....\DTS\Tasks
On a 64-bit machine, copy the component dll to the C:\Program Files (x86)\Sql Server\Dts<appropriate version>\PipelineComponent\ folder
That's going to require admin rights but you already needed them for GAC'ing the assembly as well.
This Red-Gate article seems to confirm what I'm saying as well. Developing a Custom SSIS Source Component
If you've got smart developers, you might also take a look at using Biml to create your SSIS packages. With it, you can have a single Script Task/Component defined for the common project and whenever you emit the Biml into SSIS packages, they all use the same common core bit of logic. No subtle copy/paste inheritance like you can run into if you don't go custom component route. Or you use a declarative framework for describing your packages, aka Biml.

How to use react-router with React.net

I am working on a asp.net project with react and want to use react-router. On its git repo the setup is only explained for Node.js. I found the TypeScript packages of NuGet but after installing them, I cannot build my project anymore due to compilation errors.
Does anyone have experience with installing react-router for asp.net projects?
What we did to build our application in React. We created our whole application in React in Visual Studio Code with Redux and React-Router. Webpack is used to build all the files. Once whole application is completed, we build the js (transpiled and minified) and added a script tag pointing to that url of the bundle js into our web application page (specifically .aspx page).
Now issues you might face with react-router, if you have hosted it inside a directory of your existing project. For e.g. inside root - you have folder named myapp. If that is the case - you need to make changes to your Routes in your react app to have a base name.
I tried React.NET but after doing it this way - I really liked this approach as you can separately build the whole application with all the awesome tools you have in client side ecosystem - for instance - hot reloading
Hope it helps.
I have never used React.NET, but what you can do is create a separate project, outside of your ASP.NET project. Use webpack for bundling and other purposes. Build your react project, which generates static assets (main.js, chunks, css files and images/sprites). Add these generated files in your ASP.NET project directly and set index.html as Start Page.
We have built our React project on top of this boilerplate. It uses industry-grade ways of optimization, uglification, minification, bundling and what not! Good luck!

Using local copy of an infragistics DLL vs the copy in the GAC

we are using the infragistics libraries for a long time now. But now we ran into a problem, that has been solved here Cannot select Infragistics controls in winform designer.
My more specific question now is, why does this problem not occur on all of our colleaques computers, but only on mine? We have the same visual studio solution and all of the source code is from a subversion repository.
We decided to put a copy of the infragistics dlls to our controls directory in the project, so we can deploy it later on very easily by copy and paste the files into the target directory (but still we need a setup tool to install for the first time).
How can we make sure, that the following requirements (useful or not) are met?
Updating the application still possible by copy&paste.
developper tracks the needed infragistic dlls by copying them into the controls directory (that is then copied into the application executable directory).
the problem from the link above doesnt occur
Perhaps we miss something important?
Is it bad practice to update the application by simply copying newer files to the application directory? Or is it even "illegal" in some way?
Do the infragistics tools need to be installed via setup or msi installer? Or is it sufficient to copy them?
[edit #1]:
to clarify things, as i know whats going wrong (see the link above) and what the possible solution is, i need some good arguments for or against not using the controls directory with respect to our practice of deploying the application without setup when it gets updated. We need to give our customer the posibility to update our application without a setup, because in his factory he needs to update a couple of computers at once, and if he is able to do this without the need of a setup, it will be more cost efficient compared to a setup way.
Here is my two cents:
Try setting all Infragistics libraries Copy Local property to True.
This will copy the dll to the bin folder each time you build your
application. This could solve the problem you are having with
updating the application by copy&paste;
It is better each developer to install the libraries into the GAC. I suppose all of you are using the same version of these libraries.
Otherwise, it will be real chaos. If, for some reason, you are not using same versions try to set for each Infragistics dll Specific Version to False
If all the controls are appear in the Component try (down in the designer) this clearly shows, that Designer.dll is broken or is not found. So it is always good idea to install the dlls into GAC - this should add the Infragistics Designer dll there too, and you should not have this problem.
So, install everything into GAC, set Copy Local to true and set Specific Version to false.
Also whenever you need to upgrade project containing Infragistics libraries use their nice tool Version Utility - this could save you many efforts

Shared Project for ASP.NET

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.

How to best share c# dlls in web app?

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.

Categories

Resources