ASP.NET5 is a huge reality! numerous new fashionable trinkets. Aesthetic Workshop 2015 is really great, and as I’m also a huge JSON fan, I’m extremely happy with the changed task configuration data. I wanted to build some middleware that others could call from NuGet. The workflow for this to work had some pitfalls, especially against the brand new ASP.NET5 pre-release.
This guide aims to help you (and me) make your code available to both the NuGet gallery and around the world.
Create your middleware
- Open Visual Studio 2015
- Select Documents> New Job
- Select a course library (plan) template
- Make sure the Include Application Insights in project check box is cleared
- Name your project
- Click OK
- Add your amazing middleware code
If you want to know how to get started writing OWIN middleware, check out this video on Channel9
Conversely, if you are going to see some take a look at one of my GitHub repositories which is a basic launch of some middleware
Test your middleware
I find it very useful to test my middleware before getting NuGet in the process. Next, we will most likely create a test job where we will run our middleware.
- Select Data> Include> New Project
- Select a topic about the ASP.NET web application
- Again, make sure Include Application Insights in the project is not selected
- Name your project
- Click OK
- Choose one of the ASP.NET5 preview templates
- Open the project .json. Project.json is a new configuration that declares your work.
- Under Reliances, add a brand new JSON string – start typing the name of your middleware project
- Press the Tab key twice to accept the defaults. After a few seconds, the reference will be added to the DNX and DNX Core reference lists
- Open Startup.cs and include the middleware code as well
- Run the test site and make sure the middleware is working properly
Prepare to publish to NuGet
To prepare for publishing to NuGet, you need to have “appropriate” method setup points, so post those with preparation. NuGet packages are just folder ZIP documents. We need to develop this properly to make the consumption process both enjoyable and easy.
- Create a folder outside of your option which is most likely the root of your NuGet plan
- In the new folder, create another folder called “lib”. We’ll put our DLLs here.
- By default, ASP.NET5 does not create output files. Therefore, in the middleware job properties, under the Build tab, enable the “produce output on compile” “produce_outputs” option.
- Configure the build to bootable.
- Develop your project.
- Navigate to the tasks \ artefacts \ container \ ProjectName \ Launch folder.
- Replicate the dnx451 and dnxcore50 folders directly to the lib folder you created earlier.
Release to NuGet.
We’ll most likely publish using NuGet command-line tools to keep as little as possible hidden from you.
- Download and install nuget.exe. This web link always contains the latest published variant.
- Place nuget.exe anywhere on the system and include it in the environment path to account for environment variables.
- Open the command in time.
- Type Nuget and hit Enter. This will certainly check that the nuget is correctly located in the nugetcmd path.
- Go to the tasks folder and also type in “nuget specification”.
- This will definitely create the a.nuspec data, which is a small XML file used to publish / index and mount your package. You can create it manually if you want, but the spec command will create a default file for you.
- Replicate the data. nuspec to the NuGet root folder.
- Then you want to edit the .nuspec data.
Top Tips: If you are struggling with a beta of ASP.NET5, you must set your version to beta. NuGet Gallery treats this as a pre-release.
Top Tips: Your middleware has some dependencies while absolutely nothing else depends on “Microsoft.AspNet.Http”. You must also add the DNX and DNXCore version dependencies.
- Edit your.nuspec to include dependencies
- In the command, enter “nuget
- Finally, we need to download our plan directly to the NuGet gallery.
- Open www.nuget.org.
- RegisterOR Login.
- Most likely to your account and duplicate your APIKey.
- In the command, enter “nuget setapikey” in time and paste your API key.
- The last “nugget thrust”. nupkg “.
That’s all – a bit of a hassle, but I’m sure RTM in ASP.NET5 and Aesthetic Studio 2015 will definitely bring some tooling improvements.
Before you start running – don’t forget to evaluate your plan! Try to install it yourself.
Best idea: If your package is down, it could be because there is no dependency. In my research, the exceptions were unimaginable.