This is a transcript of a video published on the blog's YouTube channel except for one section. That section was omitted to keep the video under 5 minutes. This may be helpful for fellow developers who cannot view videos during their work.
Before discussing about PnP SDKs, please note that the first preference to interact with SharePoint Online should always be Graph SDK. That is the official stand from Microsoft. In case Graph API doesn't have the feature, go for SharePoint APIs or CSOM APIs. There are 2 different SDKs or nuget packages to interact with CSOM API from .Net applications. PnP.Framework and PnP.Core to name the nugets. Today we are talking about these 2 PnP SDKs what SDK we should choose and why one over the other?
As per the documentation the PnP.Core is the successor of PnP.Framework. In that sense PnP.Core should be our clear preference. One benefit they are advertising is that it can seamlessly switch between the modern Graph API and old SharePoint CSOM APIs. That will hide the API complexities from the developer and the developer needs to learn only PnP.Core. But there are more reasons than that to choose PnP.Core.
Number of lines
First of all PnP.Core requires less number of lines to achieve a task. Take the example of Getting the title of the web.
The left side is PnP.Framework code and the right side show PnP.Core. We can clearly see that the PnP.Core works with one less line. Compare this in an enterprise application with tens of thousands of lines.
Ease of use
Now let us look at the ease of use in achieving a use case. The example we are taking is the renaming of a folder in the document library. PnP.Core has a direct Rename method to do that. But PnP.Framework uses the move method with the new name.
Support for Dependency injection
The PnP.Core SDK has out-of-the-box dependency injection support. If we are using PnP.Framework, we need to write extra code to get the .net core model dependency injection.
Size of the request payload
The PnP.Framework uses one particular URL almost always. It is _vti_bin/client.svc/ProcessQuery. This is the Fiddler screenshot of PnP.Framework making HTTP call to get a folder by relative Url. It uses HTTP POST to get data instead of HTTP GET. The request payload is XML format.Luckily response is in JSON. The XML requires more bytes than JSON for sending the same information. The different operations are achieved by changing the method attribute in the request payload.
Now let us see how the same use case is done by PnP.Core. As we can see it uses HTTP GET with user friendly URL. No request payload at all. The response payload is relatively smaller than the PnP.Framework
Here is the side-by-side comparison between the two when querying for a folder by its relative Url. Left is PnP.Framework and right side is the PnP.Core.
Logging
Now coming to the logging aspects, PnP.Core is already following the .Net programming model and honoring the ILogger API. By adding the required configuration in the appsettings.json file we can get the logs into the required destination.
Observability
Observability is important to run a production workload. Tools such as Azure Application Insights normally log the URLs and their HTTP verbs. That will help us to understand the system behavior and also to troubleshoot issues. We have already seen that the Url is used by the PnP.Framework is mostly the same. Adding to that, it always uses HTTP POST with parameters to distinguish the operation which makes. We cannot distinguish the operation type by the HTTP verbs.
Error handling
In a normal web system, when an error happens it will return respective HTTP status codes. Never Http 200. Look a the fiddler trace when querying with non existing folder path from PnP.Framework. it always returns HTTP 200. In case it errors out, the error message will be inside. Production observability systems can never detect errors like this and proactively alert the dev team.
Otherside, PnP.Core error out with proper HTTP status code. In case the folder URL is not present, we get HTTP 404 back, and will be handled properly by the production monitoring systems.
Contribution to Library
The PnP libraries are open-source and maintained by the community. Microsoft is not giving any warranty or support for these libraries. In case we end up facing an issue and need to get fixed quickly we need to fix ourselves and give a pull request.
Look at the source code of PnP.Core and PnP.Framework. The PnP.Core is relatively simple to understand. Meaning easy for us to fix the bugs in that library. It simply prepares the Url uses an internal method to execute that Url and returns the result.
Can we completely avoid PnP.Framework?
Not really. The PnP.Core is not a feature-complete SDK. There are features that are not available in PnP.Core.. In such situations, we need to use PnP.Framework. One place they are telling PnP.Core will eventually replace PnP.Framework. However, when a feature request was created to bridge the gap in CreateCopyJobs-related tasks, they informed PnP.Core is never going to implement that feature. In such situations we need PnP.Framework forever.
This relates somewhat to a post in this blog about the dilemma of choosing Net SDK to interact with SharePoint". Since there are multiple .Net SDKs the selection of one is tricky. Now think about multiple APIs to interact with. For simplicity, we are now concerned about only SharePoint Online by avoiding SharePoint services on-premises.
This post tries to visually represent the APIs and corresponding .Net SDK to interact with SharePoint Online.
Generated using PlantUML. Click on the image to get svc where the links are navigatable.
Historically SharePoint was used for content management. Normally an admin will do basic things to provision the site and add users. But all most everything is automatable as it is built on top of API. When it comes to invoking APIs, we can use raw HTTP requests or use an SDK to invoke the same.
Many SDKs are available for .Net applications. Trying to see what is for what.
CSOM
This is the original SDK from Microsoft. It was an installer when it started back in 2010, but is now available via nuget. CSOM² stands for "Client Side Object Model". The CSOM seems still maintained and supports the latest .Net versions as well. But their documentation¹ says "We're no longer updating this content regularly. Check Microsoft Product LifeCycle..." Below is the screenshot of the package as of writing this post.
In the announcement to make this API .Net Standard compatible³, Microsoft clearly says to use Graph APIs when possible with the Graph SDK nuget package. Use this if the Graph API is limited in features.
Still maintained, new releases are coming but kind of retired and recommends using Graph SDK.
Microsoft Graph SDK
There are server-side API differences as well along with the client SDK changes. Earlier we had SharePoint API⁵ and now we have modern Graph API⁴. They are different APIs⁶. The main difference is Graph API is not just limited to SharePoint but applicable across Microsoft 365. Graph API can be consumed by Graph SDK for .Net to work with SharePoint Online. This Graph SDK is developed as open-source software but it is incomplete.
Latest and supported. But incomplete. Use CSOM library when we hit incomplete feature.
The PnP Story
Life should have been easy if we had to deal with the above 2 alternatives. But there is one more before we can complete it. The PnP SDKs. PnP⁷ stands for Patterns and Practices
These are pure open source community SDKs not directly supported by Microsoft and have no SLAs.
But we can see Microsoft as an active contributor and even aka.ms link.
This open-source library was created as an extension to the CSOM library. But this has grown in complexity and they started developing PnP Core SDK which is clean, lean, has better test coverage, etc. But it is incomplete like the Graph SDK that we saw earlier.
Please note the older SDK is "PnP Sites Core" and the latest SDK is "PnP Core". The word "Sites" in the middle is missing.
Archived in GitHub. Use PnP.Framework or PnP Core SDK
PnP Framework
The PnP Sites Core supports till .Net 4.6.1 only ie Windows only. Meantime, they created another open-source library names PnP.The framework that supports .Net Standard and latest .Net Frameworks and the .Net.
The interesting thing is the PnP Framework nuget depends on the PnP Core SDK nuget.
The above image credits go to the PnP Sites Core repo that explains the roadmap.
Summary
This just introduces the most common options available. Very less details. As developers, we should always look at the Microsoft Graph SDK to achieve our goals. If not supported look at the other libraries.
Update 2023-10-05
There is documentation⁹ in choosing the right SharePoint API based on the client application. That is helpful if we want to work with SharePoint from non .Net applications or platforms other than Windows.
If you want to skip all my stories and want to understand what is the .Net SDK to use with Azure ServiceBus, please use the Azure.Messaging.ServiceBus nuget package. No more suspense.
Others welcome to the story.
All we wanted was to dequeue Azure ServiceBus Queue messages in the synchronous fashion inside the .Net 4.6.1 application.
WindowsAzure.ServiceBus Library and Microsoft.ServiceBus.Messaging namespace
The first nuget library we got was WindowsAzure.ServiceBus which has Microsoft.ServiceBus.Messaging. This library has a class called QueueClient. That has a synchronous dequeue mechanism using ReceiveBatchAsync() method. Unfortunately, this library needs .Net 4.6.2. If it is not an enterprise, upgrading the .Net framework version would not be a big deal. But upgrading an application having half a million lines of code in the enterprise that too working in regulated industry is a thing. So had to say bye to this technique.
Another reason to say bye is the new library named Microsoft.Azure.ServiceBus and the migration instructions from WindowsAzure.ServiceBus.
Microsoft.Azure.ServiceBus Library and Microsoft.Azure.ServiceBus namespace
This library has migration guidelines from the communityat least. It appeared to be the way to go. It supports .Net 4.6.1. This also has a QueueClient class. But this QueueClient doesn't have a mechanism to synchronously dequeue messages. It accepts a callback via RegisterMessageHandler() and suitable for daemon apps. Our app is not a daemon.
We got stuck here and since we had a channel to MSFT we decided to activate it. They suggested a third library which comes next.
Later we figured out there is a way in Microsoft.Azure.ServiceBus library to dequeue messages in sync way. This link explains the same using MessageReceiver class. But we are planning to use the below one which Microsoft confirms the way forward.
Azure.Messaging.ServiceBus
As per Microsoft, this library is the way to go. They are making all SDK names starting with Azure prefix now. The good thing we are seeing is that now Microsoft is preparing the migration guide from older SDKs.
It also has the code snippets we tested using other libraries. Get the full project to run it.
Conclusion
Those libraries are still in development. That is the interesting thing.
Library
Last release
WindowsAzure.Messaging
v6.0.3 - 5 months ago
Microsoft.Azure.ServiceBus
v5.1.1 - 24 days ago
Azure.Messaging.ServiceBus
v7.0.1 - 25 days ago
The above table shows the recent releases as of writing this blog post.
Due to NDA, I am not supposed to disclose the names. But big thanks MSFT guy(s) for your support. Innovation and changes are always welcome from Microsoft. But one humble request is to slow down innovation a little bit and consider stability. That helps people like us who develop apps for the regulated enterprises.
To directly jump to the problem this post is dealing with by skipping the story, directly jump to the last paragraph in this section.
When we were developing .Net libraries or third-party components in the early days we had to keep one project per framework version. That is because there would be more than one version in the mainstream at any time. Though Visual Studio 2008 onwards there is some sort of multi-targeting which matured with VS 2010, it was not easy to publish libraries from one project targeting different framework versions.
The need to target multiple versions became intense with the introduction of .Net Core. Both Full .Net Framework, as well as .Net Core, keep getting new versions.
But it changed totally when Microsoft introduced multi-targeting library projects in Visual Studio 2017. For simplicity skipping the PCL(Portable Class Libraries) which was introduced in between to deal with common code base for Silverlight and .Net Framework. At that time, there was real confusion about what library project to choose when we create new. Later Microsoft introduced JSON based project file for .Net core which dropped with a migration path.
The new project format really simplified the .csproj files. Initially, it was more related to the .Net Standard but later it is used for different purposes as well even for console apps. Let us not get into .Net Standard as differentiating it is another post by itself. Finally, the new project format got the name SDK-Style project which we can identify by the below tag in the project file (.csproj)
<ProjectSdk="Microsoft.NET.Sdk">
One of the earliest blog posts explains what is the vision when they revamped the project file format. No listing of files inside the project file, can produce nuget directly without nuspec, easy modification without IDE, etc... were some. Until then the csproj was considered as only software editable file format though it is XML. But with the SDK-Style project format, though it is still XML, humans are also allowed to edit manually. More details can be found here.
Now the csproj is more like the NodeJS development where the packge.json is human editable. Really dreaming for a day when Microsoft says "develop with NodeJS or something else and host in Azure". Just a dream.
Let us come back to the purpose of this post. Here we are seeing how to convert existing old nuget library projects to modern SDK-Style library projects which can target multiple frameworks and versions including from .Net 4.5 to .Net Core 3.1.
Existing approaches
The easy way most of the internet says on converting existing projects to a multi-targeting SDK-Style library project is to create a new project. Then just copy-paste the files from old project location to new. Since the new project format doesn't require all the files to be added to the project file its easy as just copy. Links are given in the references section.
Just compare with NodeJS development where package.json doesn't need to know all the files.
There is another way to convert the projects to SDK-Style. First, convert the nuget package references from the packages.config to <packagereference> tag in csproj. Then use a tool to migrate the project file. There seem multiple tools listed below though they point to the same GitHub repo. Maybe one is a wrapper over other when VS 2019 released.
However, it seems easy to convert by hand, if our project is not that much complicated and confirms the compatibility. The only problem is that we need to clean the project which is not required if we start a new project and copy files.
Manually porting project to SDK-Style library project
Below goes a diff of manual porting of one project. If the iFrame is not loading directly go to the GitHub URL. Another difference is that the SDK-Style doesn't really require the Assemblyinfo.cs
Manually porting test project to SDK-Style
The same can be applied to test projects as well. The link to the comparison is here.
Please note that it worked smoothly as this project is simple and only one person handles all at this point. When working in Enterprise environments or a large team environment, it would not be efficient as following the steps such as evaluate compatibility, refactoring projects to smaller pieces before doing anything.
When we develop an open-source project in GitHub, it is a good practice to show how perfect we are doing things through badges. One of the measures is code coverage. Code coverage means how deep our code is tested.
This is a post to discuss how to set up code coverage for a multi-targeting .Net library by analyzing how it is done for DotNet.Helpers nuget library. Below is the live badge of DotNet.Helpers.
Test frameworks
There are multiple choices here. The best way is to go with the native MSTest.
Coverage file formats
There are different formats to store the code coverage. OpenCover is a stable format that uses XML to store the results.
Tools
OpenCover
This tool support .Net Core natively. It has 1.2k GitHub stars as of writing this post. The problem with the tool is that we cannot generate the coverage report using dotnet cli. Also, it supports only Windows. Is that a problem in the .Net world. Maybe not now, if we are using CI/CD provider with Windows. But it will be a consideration when Microsoft stops Windows and asks all of us to use Linux. Their current direction is 'Develop anywhere, use any tool but host in Azure'.
//This doesn't seem working dotnet test with --collect: "Code Coverage"
Coverlet
This is another great tool to get the results. It can be integrated with the .Net build system. Coverlet doesn't merge results automatically when we are using the multi-targeting library. Though it defeats the purpose, we can work around using different methods.
The main reason for using Coverlet is that it works natively with dotnet test command. We will see the syntax later in this post.
Coverage visualizers
Generating a file is not enough. We need somebody who can track coverage and display beautiful reports. Often hosted services with freemium pricing model.
DotNet.Helpers library uses CodeCov for tracking coverage.
How DotNet.Helpers implemented code coverage
It has 3 steps
Setting up the coverage generator tool
This step is a one-time activity. It installs coverlet.msbuild nuget package
Install-Package coverlet.msbuild
Please make sure the package is installed on the test project having the test classes.
Generate coverage report
This step has to happen with each build. The step is mentioned in the appveyor.yml. Similar to AppVeyor, it can be configured with any CI/CD provider. Below is the simple command to generate the report.
dotnet test "DotNet.Helpers.Tests\DotNet.Helpers.Tests.csproj" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Threshold=100 /p:ThresholdType=line --configuration Debug --no-build
The above command should be executed as a single unit. Multiple lines are used in this post for easier understanding.
The switch /p:Threshold=100 means it requires 100% code coverage and /p:ThresholdType=line tells the coverage is at the line level. Meaning all the lines in the library should be executed at least once during the unit testing.
The command will execute tests against all the framework versions mentioned in the test project (.csproj) file. But overwrites instead of merging as we didn't mention the target version in the output file name.
Upload coverage report
Uploading to service is optional but it helps to show the badge on how good our library is tested also reports. DotNet.Helpers library uses CodeCov service. Uploading the report to CodeCov can be done using the below command.
The choco is the command to install software using Chocolatey. The $env:CODECOV_TOKEN is optional. CodeCov can check whether it is running as part of the CI/CD process inside AppVeyor and if the criteria satisfy, it can magically upload without the token.
Adding Badge
In GitHub readme.md we can embed the badge code as below.
Every serious developer might have accumulated a set of reusable code snippets over the course of their career. Mostly those snippets help them to speed up work. With the advent of packaging techniques such as nuget, NPM it is very easy to share between projects. 'DotNet.Helpers' is such a library for sharing reusable .Net code which makes the development faster.
.Net uses the nuget package repository. There are different versions in .Net and maintaining a separate project and nuget package for each version is not practical.
.Net has a solution for the same and its called multi-targeting.
This post is to discuss some of the use cases, issues faced during the development of 'DotNet.Helpers' library. Below is the list.
What are the use cases in multi-targeting?
Conditional references
Conditional compilation
Conditional inclusion of files
Unit testing against each framework
Documentation against each framework
But before discussing in details lets see how the internet says about it.
Microsoft way
The first thing Microsoft ensure that the nuget package structure is independent of how we compile and build package. Basically, the nuget package is a zip file. If it has the right folder structure, and metadata it just works.
The tooling support for multi-targeting started from VS 2015 onwards. SDK-Style projects help us mention all the frameworks in a single .csproj file itself.
How other libraries did it?
Though Microsft has tooling for multi-targeting, it is difficult to exact guidance to start our own multi-targeting nuget package. Better to look at how other libraries did the same.
NewtonSoft.JSON - This is a famous library for JSON related operations. It uses the SDK-Style project and CI/CD done using AppVeyor and Azure Pipelines. But it is a little difficult to start a new project by just following it.
An easier way is documented at west-wind.com. It explains how single repo can be used to hold source code which can be used to build a nuget package having different target frameworks.
Use cases
Most of the solutions presented below are tested against VS 2019. None of the features require a paid version of VS. Just community will be enough.
Conditional references
When we develop our library, we may be referring to other assemblies but not required in certain frameworks. For example, mscorlib.dll is only needed when we target the full framework. Similarly, there are more. Those references can be made only to the full framework using the below method.
The same which works for assemblies can be extended to nuget library references too. Here is the link from the same repo.
Conditional compilation
This is the same as what is there from the beginning. We can write code using the conditional compilation constants and the value of constants can be controlled from the SDK-Style .csproj file.
Here is the link to defining the constant based on the framework version and here is the link to using it in the source code.
Conditional inclusion of files
Another scenario is including the files based on the framework. This is useful mainly if the entire file is framework dependent than some sections inside.
It can be done by using the same technique which can be done in the .csproj file.
The approach is the same as how we are developing the library. Create a unit test project with the SDK-Style template. Use conditional inclusion and compilation techniques described above. Based on the below tag in the test project file, tests will be run against all the mentioned frameworks.
This is the tricky part. To be frank there is no solution implemented for this in DotNet.Helpers library. It uses DocFX to generate documentation and generate using a full framework which is kind of superset of others.
Generated DoxFX contents, doesn't seem to be providing any way to filter APIs based on frameworks.
Support for AppVeyor for CI & CD
This is a bonus section. If we get the project set up correctly, we can easily integrate with CI/CD systems such as AppVeyor. It is free for open-source projects.
Over the past 13 years, to be precisely from Nov 2005 till today, I had written lot of .Net code for day job as well as to personal projects. When I started .Net, I though yes I will master it and enjoy rest of my career. But I soon realized that is not going to work with the collapse of Silverlight. Microsoft was telling or people was arguing that Silverlight will not die as Microsoft is using it for their Azure portal. All of a sudden MSFT replaced Azure Silverlight site with HTML and that was kind of last nail on Silverlight. More details on it can be found in my last post in SilverlightedWeb blog which is a readonly blog now. Then I thought Silverlight technology's end is inevitable as it is replaced by HTML5 but .Net will live long.
That thought got shaken when MSFT released their so called code editor now becoming full fledged IDE named VS Code. That didn't use WPF which was the star of desktop programming from MSFT at that time. Instead it used Electron from Github which depends on Chrome. Yes, the browser from Google powering web. Essentially we develop browser application and show as standalone executable. That was the time I said good bye to WPF technology. More details here. Then whats left, only ASP.Net which was and still struggling to compete with NodeJS. Don't bring Windows Phone here as that is the one of very hand countable things MSFT properly shut down. No idea how long something called UWP will live.
.Net Core
Finally something came named .Net Core. Its like Angular 1.x and 2. Only name is same, internally all most new. That is what now MSFT fans betting on, as return of .Net. .It is advertised as another true cross platform which will run on Linux! Yes its the second cross platform .Net. The original one also advertised as cross platform with the intermediate language and JIT similar to JVM echo system.
The another factor is performance. .Net Core is expected to beat NodeJS for serving http responses. There are some case studies people are claiming it is faster such as on Bing.
Another areas where .Net was weak is AI, Machine Learning, distributed computing etc... Now there is ML.Net SDK also announced.
Yes it may be faster and may become powerful than Python in AI programming. But will this technology enough to feed my family in future?
So what is next?
Personally I don't see a bright future for .Net unless .Net Core becomes a big hit. So better to reduce focus on .Net and consider other technologies as well seriously. Electron for desktop development, Angular + NodeJS for web front end, Scala for distributed programming etc...
But what I should do with all my .Net knowledge acquired in past 13 years as I still have hope on huge return of .Net core?
Offload from brain and move on. The better place to offload code level techniques is a nuget package at this point. I could have added the helper classes to my first nuget package, but unfortunately that was towards a specific problem of Orchestration. Hence I had to start another nuget library for my helper classes and coding techniques. Link to Github repo below.
This library uses multi targeting feature so that one code base can be compiled to multiple targets. This is useful especially to provide libraries for .Net Core.
Thanks to AppVeyor for giving free CI&CD support to publish to nuget repo.
Why I didn't join with other helper nuget libraries is described in the readme of the repo.
There is no need to explain about the importance of nuget package ecosystem to .Net development community. Now a days its very difficult to consider someone as .Net if he don't have a nuget package. Of course now I can tell because I just published my first nuget package :)
How to package our .Net library(.dll or scripts) as nuget package and publish to www.nuget.org is documented very clearly in nuget web site. Link below.
So I followed the same guidelines and published it. All manual and using Visual Studio and command line tool nuget.exe. Its available in below location.
Manually publishing every time from our development machine is really boring task. Its highly repetitive. Also how to ensure that the the library actually works after each change? If we cannot solve our this problem, how can we solve other's problem.
As everybody knows, the answer to this problem is continuous integration. If that is hosted its too easy. If its free too, don't ask any more questions, just do it.
As we have seen in some of previous posts, AppVeyor is the best place for doing free hosted CI & CD for .Net projects at this time. I will highly recommend than Microsoft's Visual Studio Online service which gives some free build minutes. Infact Microsoft itself using AppVeyor to do their integration.
Below are the official AppVeyor documentation about how to setup CI for nuget projects.
Compilation of the project and running unit tests are trivial. There won't be usually any issues at all. But we want to automatically create the nuget package and increment it's version, we may need to think twice.
There are basically 2 options. The first option is kind of obsolete now.
Explicitly run our own script to auto increment the nupkg file version and fire the nuget pack command to create the .nupkg file
Use AppVeyor's out of the box settings to auto increment the version.
Enable Assembly patching in AppVeyor
Use $version$ token in version property inside .nuspec file
Enable the nuget build in AppVeyor to automatically package the file.
We can take the second approach which is out of the box which don't.require any coding. Remember less code less defects!!!. Once this is working file we can see the .nupkg file in the build artifacts. From there we can push via AppVeyor itself. We need to setup our nuget API key either in appveyor.yml (encrypted) or in the web interface.
Recently I moved to our company's US office located at New Jersey. When I moved to new office, I had to return my laptop to Kochi office. There was arrangement done to upload all my files to company's FTP server so that I can download once I get machine from US office.
When I got the new machine and compile one of my visual studio solution, it showed a wired compilation error as below. It was not associated to any of the projects inside the solution.
Error 66 The "EnsureBindingRedirects" task failed unexpectedly. System.MissingMethodException: Method not found: 'System.String System.Reflection.AssemblyName.get_CultureName()'. at Roxel.BuildTasks.EnsureBindingRedirects.MergeBindingRedirectsForReferences() at Roxel.BuildTasks.EnsureBindingRedirects.Execute() at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult)
The google says its because of missing culture name in web.config file. I corrected it, in one of the MVC web project in the solution but the issue still persisted. Then a deep google gave insight to async related dlls of Microsoft. At some point, I had installed a nuget package named 'Microsoft.Bcl.Async' which helps to use the async keyword in pre .Net 4.5 versions. I just removed that package and it started working. For me that solution is just a single place testing solution where it contains all types of projects so that I can try any kind of PoCs.
As of a new programmer those are the dll which increase the size of their project. Before we remove these dlls we should know what are those dlls and their duties? Those are the dlls used for Bundling and Minification. By default the Visual Studio adds those nuget packages in the newly created MVC web application.
Next thing we need to understand when we should remove those and why we need to remove? If you are creating a production application, never remove as those libraries will increase the performance of our application. We may not require if we are doing any of the following.
Creating a PoC and mailing the same which don't deal with minification and bundling.
Below are the steps proper steps if we have the solutions in proper condiction
Open nuget package manager console or UI.
Execute the command Uninstall-package 'package name'.The order of removal is as follows
Microsoft.AspNet.Web.Optimization
WebGrease
Antlr
Follow the common steps for method 1 & 2
Method 2 - Manual removal
Use these steps if you are not able to make it via nuget.
Manually remove the reference to the Antlr3.Runtime.dll, WebGrease.dll & Microsoft.AspNet.Web.Optimization from solution explorer
Follow the common steps for method 1 & 2
Common steps for Method 1& 2
Remove or exclude the App_Start\BundleConfig.cs file.
Remove the method call BundleConfig.RegisterBundles(BundleTable.Bundles); from Global.asax.cs
Remove the import using System.Web.Optimization; from all code files.
Remove the @Scripts.Render() and @Styles.Render method calls from your view files
It will make the application fail, if we are using scripts and styles. You need to explicitly add the styles and scripts to the application For example to render styles add the below line.
Remove the "System.Web.Optimization" entry from views\web.config file->
<system.web.webPages.razor> -> <namespaces>
Clean the solution and delete everything in \bin folder
Method 3 - Remove the packages folder and bin folder and ask the user to sync nuget packages
As you see the problem its about sending the sample code to other user and his easiness to run the same. If the target developer knows about nuget, let him install the nuget packages before running the sample. This is the actual solution provided the target developer have enough internet connectivity to sync nuget packages.
I have tried this in MVC 4 & 5 from VS2010 & VS 2013 without any issues.