How to configure sitemaps using MVCSiteMapProvider with StructureMap DI - asp.net-mvc-4

I StructureMap as a way to do DI in my project. I want to create sitemap in my project.
I install MvcSiteMapProvider MVC4 StructureMap Dependency Injection Configuration from NuGet.
it requires manual config but I don't know how to config this.
thanks for your helps

If you installed MvcSiteMapProvider.MVC4.DI.StructureMap into your project, it does not require manual configuration. This package is for use when you don't already have DI in your project - it contains a composition root which is meant to be used as the single place to register all of your DI configuration for your entire project.
However, if you installed MvcSiteMapProvider.MVC4.DI.StructureMap.Modules into your project, it requires manual configuration. This package is meant to be used in projects that have a pre-existing DI setup. You just need to follow the instructions in the readme file in order to add it to your existing configuration. The exact procedure and could vary greatly from one project to another, but the readme contains all of the required and optional lines of code that will need to be added. The key is that you need to ensure that only 1 DI container is instantiated for the entire project and that all of the modules are registered with it.
Do note that MvcSiteMapProvider.MVC4.DI.StructureMap depends on MvcSiteMapProvider.MVC4.DI.StructureMap.Modules, so you can easily downgrade with a single package manager command.
PM> Uninstall-Package MvcSiteMapProvider.MVC4.DI.StructureMap
Make sure you don't use the -RemoveDependencies option.

Related

CI build failed in case project reference is from another .net solution

I have two independent .net projects. One is like a project which is baiscalliy to process invoice and another project is something which I am calling as common as I am keeping all sharable/reusable code under that.
Now any project can consume this common-project by adding it via add Existing project option so that source code will not move to consumer project which is Invoice management in my case.
Now if I add common project as reference and run my CI pipeline its failed as its not able to find the path of common project which is obvious as it may be different from my local machine to build server.
Now the solution that I am aware of are below :
Make common as Nuget package and use it under invoice management.
Build common project dll at some centralized file server and give that path in Invoice management
for reference instead of absolute path.
Both solutions are not simple to implement so I am looking for any better quick solution for the situation where project setup is like this and CI build has to execute.
The best would be actually reference via NuGet package. However, there is a third option which I do not recommend. You can use multiple repository pipeline. You will checkout there two repositories. In thi case you have to mimic folder structure wich you will get on AzureDevops. Otherwise build will fail as it will not find the references.

Include git information on parceljs build

I have a TypeScript/React web app that uses ParcelJS and I would like to have either a step in the build or a simple way of using a resource file that holds git information.
Not sure if there is something that can generate the git information during the build, I'm using npm to launch parcel.
If parcel can load a resource file and make it accessible that could also work by having properties.
My end goal would be to display version and git commit point in the webapp.
I'm going to assume you're using parcel2 (I'm not sure this would be possible in parcel1).
Parcel2 uses babel to transpile typescript by default (through the #parcel/transformer-babel plugin). The babel configuration for this plugin can be over-ridden by simply including a .babelrc (for configuration relevant to only a subset of the project) or babel.config.json file (for configuration that will apply to the entire project). See this scenario matrix that I made in the process of fixing this bug for details about exactly what babel config files should be picked up by parcel. (The "proposed fixes" are merged into parcel2 as of the latest nightly release).
With the ability to supply your own babel configuration, you should be able to use this babel plugin to inject git repository information into your code.
(Since you're using typescript, you'll also need to make sure to include #babel/preset-typescript or #babel/plugin-transform-typescript in your babel config as well).

NuGet package contentFiles artifacts installed as links in ASP.NET Core MVC project

We have an internal JavaScript library that we'd like to share between multiple projects. Actually we are already sharing it via file copying, but this has (predictably) resulted in multiple forks of the code.
The consuming projects are a mix of "full" ASP.NET (MVC and Web Forms) and ASP.NET Core MVC. (I'm planning on creating two separate packages.)
Installing into ASP.NET projects seems to work fine, but I'm having problems with ASP.NET Core.
Initially I had all the artifacts within a files element, and nothing at all was showing up in the consuming project. After re-reading the docs, I realized that ASP.NET Core projects would use a PackageReference ... so I would have to use a contentFiles element instead of (or in addition to) a files element.
I created a contentFiles folder and a script to copy the requisite files from the source project folder structure into contentFiles/any/any/wwwroot/lib/ourAwesomeWidget, and modified the package manifest accordingly.
This works. Sort of. The package appears to get build correctly. The files do get added to the consuming project, but they get added as links; the actual files (the link targets) reside in my local package cache.
The relevant portion of the package manifest is:
<metadata minClientVersion="3.3">
...
<contentFiles>
<files include="**/*" buildAction="Content"
copyToOutput="true" flatten="false" />
</contentFiles>
</metadata>
<files>
<file src="contentFiles\**" target="contentFiles" />
</files>
Part of the issue is that I don't find the docs very clear concerning contentFiles. All the examples show a single file element ... but the include attribute on the files element is required, so it's not clear what the individual file elements would even do.
Is there a way to get the actual files (not links) added to the consuming project? Or, alternatively, is there a way to get the package to install as a "normal" package (rather than a PackageReference)?
Update:
I did some further digging and found this answer by #Martin to a similar question -- but he answered this one before I had a chance to update it.
It appears this behavior (adding files as links) is by design.
I find this highly unsatisfactory, because (as #Martin points out), our JavaScript library will not be available during development on consuming projects.
But part 2 of my question still stands. According to the docs,
By default, PackageReference is used for .NET Core projects, .NET Standard projects, and UWP projects targeting Windows 10 Build 15063 (Creators Update) and later.
Is there a way to trigger the non-default behavior, i.e. allow .NET Core projects to consume packages other than via PackageReference?
contentFiles are supposed to be added as a link. The contentFiles section controls the msbuild items that are generated for these files into the obj\projectname.csproj.nuget.g.props file.
The copyToOutput="true" will cause the items to be copied to the output and publish directory. However that does not help you when running the application during development, since it will be run from the project directory, not the output directory.
Consider consuming client libraries via npm (since bower is deprecated).

Which one do I need? EntityFramework.Core or EntityFramewor.MicrosoftSqlServer?

I have been trying to find out the differences between EntityFramework.Core and EntityFramework.MicrosoftSqlServer to figure out which one of the packages I need. I did not notice until today that in my Visual Studio solution, which has both a WebUI project and DataAccess project, that the WebUI only includes EntityFramework.MicrosoftSqlServer while the DataAccess project only includes EntityFramework.Core.
What is the real difference between the two and when should I include one vs. the other vs. both? I am using ASP.Net 5 Core for the entire solution.
EntityFramework.MicrosoftSqlServer depends on EntityFramework.Relational which in turn depends on EntityFramework.Core. Restoring the project is about creating the dependency graph and installing all required packages (regardless of whether they were specified in your project.json or not) into the project.
In your case you specified just EntityFramework.MicrosoftSqlServer but during restore the other dependencies (including EntityFramework.Core) will be pulled so it is not necessary to specify EntityFramework.Core explicitly.
If you are on dnx you can see the dependency graph using dnu list (you can use the --details flag to see even more details) or, if you are brave, you can take a look at the project.lock.json file.
Both are required but if you add EntityFramework.MicrosoftSqlServer then EntityFramework.Core will be added for you as it is a required by EntityFramework.MicrosoftSqlServer.
EntityFramework.Core contains all of the core code of EntityFramework such as DbContext, DbSet and any IQueryable extensions aswell as alot of other internal code.
EntityFramework.MicrosoftSqlServer contains the database specific sql syntax and connection code for sql server. There are other database providers available.
Available database providers:
EntityFramework.InMemory (this is good for writing tests that dont need a database)
EntityFramework.Sqlite
EntityFramework.MicrosoftSqlServer

How do I avoid having to manually tweak Import-Package headers with Maven bundle-plugin?

I'm happily using the Maven bundle-plugin to create OSGi manifest headers for my modules. However, when there are configuration files that pull in classes which aren't referenced directly in the code, the plugin can't tell which packages it's going to need.
One example is a bundle with domain models that constitute a Persistence Unit for JPA. The driver class is part of the PU configuration and either set in an XML file or at runtime when the EntityManager is instantiated. I have to manually add an Import-Package header for the driver class that I want to load, or I get CNF errors.
Another example is a Struts war, where the web.xml pulls in the Struts dispatcher that's otherwise not found anywhere in the code and has to be manually added to the headers.
How can I avoid this?
I tried adding the required packages as dependencies with a provided scope, but that didn't help.
In the plug-in section of the bnd configuration you can specify plug-ins to analyze these files and contribute to the import-package header. For spring it looks like this:
<_plugin>aQute.lib.spring.SpringComponent</_plugin>
I am not sure, what descriptors are supported on top of spring. Just take a look at the source (it's in the Apache Felix SVN) and see for yourself. In the worst case you have to write your own plug-in, but at least it is possible! Also peter kriens site about the bnd explains the usage and some internals.
Other then that I am not aware of any simple solution.