Add HttpModule to web.config in Nop - web-config

The issue seems to be that the syntax
<configuration>
<system.webServer>
<modules>
<add name="HelloWorldModule" type="HelloWorldModule"/>
</modules>
</system.webServer>
</configuration>
is looking in the site bin folder, however as far as I can tell nop
commerce only puts a plugins dll in the Plugins folder.
What I've tried, that hasn't worked so far
putting the syntax in the web.config that exists in within the plugin folder
wrapping the syntax in the <location path="..."> tag
I realize that I could pull the class out into it's own project and manually drop the compiled dll into the bin, but I'd like to avoid this.
Has anybody used httpmodules within a Nop Commerce Plugin?

Related

How do I include NuGet packages in my solution for .Net Core projects?

With classic .Net projects, if I added a reference to a NuGet package, it would get downloaded to a packages folder and I could check that into source control along with the rest of my code. This allowed any developer to download the code, along with the NuGet packages, without having to set up a package source to separately download the packages. This is not how .Net Core projects work. There does not seem to be a packages folder for the solution, and it is up to each developer to set up the custom package source and download the packages when they get the code. Is there a way to configure the .Net Core project to do like the classic .Net projects did and manage a packages folder?
A lot of NuGet behaviour can be controlled via NuGet.Config files (See this reference for more details)
If you place a NuGet.Config file next to the solution with the following content, you can override the location that the packages will be restored into:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="globalPackagesFolder" value=".\packages" />
</config>
</configuration>
If the problem is that you'd need to set up additional sources in VS on every machine, you can also add those sources via a NuGet.Config in your repository so VS will pick up the feeds to use when opening a solution:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="CompanyFeed" value="https://my.company.com/private/nuget" />
</packageSources>
</configuration>
If you have no feed to host packages and need to include packages with the solution, you can use a directory containing .nupkg files as well in NuGet.Config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="local" value=".\NuGetPackages" />
</packageSources>
</configuration>

visual studio code and private nuget

I have a library that comes from a private nuget feed. I have the url and credentials for that but dont know how to connect to the feed properly with visual studio code. I am using dotnetcore framework.
I created a Nuget.Config file in the root of my console application with the feed url and username and password but this didn't seem to pick up the packages from that feed when imputting them in the project.json. Even doing a restore would produce errors.
Does anyone have an example of how they would set up a project to do this? I know it is not normal to have the Nuget.Config file in the project but this is a test project so would not live there once the project got past proof of concept.
My nuget.config looked like this
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="CustomRepo" value="https://nuget.feed/nuget/" />
</packageSources>
<!-- Used to store credentials -->
<packageSourceCredentials>
<CustomRepo>
<add key="Username" value="something" />
<add key="ClearTextPassword" value="thepassword" />
</CustomRepo>
</packageSourceCredentials>
<!-- Used to disable package sources -->
<disabledPackageSources />
</configuration>
Apoligies this is now resolved and working with the nuget.config file in the root folder. I dont know what I did. Only thing I did was re-type the whole xml but dont know what what would have done. Anyway it is working which is great.

Can I get the location of the packages folder for the current solution when applying an xdt?

I want to install a design time plugin for a visual studio extension (ie runs when using visual studio, and not when the application is running). This requires that I modify the app.config with an entry that points at the dll containing the extension code. The plugin is installed via nuget and if I add this dll to a folder under the project and use a fixed path in the app.config.install.xdt then everything work ok. However what I want is for the xdt to insert a value which points to the dll in the packages folder, where it gets installed via nuget. My problem is that the relative path to the nuget folder is not fixed for the projects. Each project may be in a different folder (several folders deep inside the solution folder) and not just in a direct child of the solution folder, so I want to be able to use some variable in my xdt.
Currently I have this in my xdt:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<specFlow>
<plugins xdt:Transform="InsertIfMissing">
<add name="NCrunch.Generator" path=".\SpecflowPlugins\" type="Generator" xdt:Transform="InsertIfMissing" xdt:Locator="Match(name)"/>
</plugins>
</specFlow>
</configuration>
but I want something like this:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<specFlow>
<plugins xdt:Transform="InsertIfMissing">
<add name="NCrunch.Generator" path="$(SolutionDir)\packages\Specflow.Ncrunch.1.0.0\lib\net" type="Generator" xdt:Transform="InsertIfMissing" xdt:Locator="Match(name)"/>
</plugins>
</specFlow>
</configuration>
is this possible in xdt? if not is there another option for getting this to munge the app.config correctly when my nuget package installs?
The XDT syntax doesn't allow replacement tokens such as the one you put in your example.
One option I can think of would be to modify the app.config.install.xdt file in your init.ps1 PowerShell script, replacing the tokens for the actual values before the XDT transform is applied by NuGet.
For more information regarding init.ps1 see: Creating and Publishing a Package

Use Maven Cargo to install Wildfly with Keycloak

I'm trying to use Maven Cargo to produce a Wildfly container and get Keycloak running on it. I've been at this for a while now and the way I see it there are two ways to go about it. I could either use an artifact installer for Wildfly and then try to deploy Keycloak to it, or I could use a zip installer and have it install Keycloak's appliance build. I have the basics of both solutions working although neither of them work all the way.
They both seem to have downsides. If you use the artifact installer you have a more stable installer, but deploying the war takes quite a bit of lower level configuration for Wildfly. (Deployment Instructions). On the other hand, the zip installer requires finding a place to download a distribution from and then manipulating it a bit before Cargo will recognize it, because the zip structure is not what Cargo seems to be expecting.
I'm getting the zip from here: https://repository.jboss.org/nexus/content/repositories/releases/org/keycloak/keycloak-appliance-dist-all/1.0.2.Final/keycloak-appliance-dist-all-1.0.2.Final.zip)
Thanks in advance guys.
I figured out a way to do this and attached the relevant pom snippet. The only oddball piece here ends up being the files section. It's being used to deploy a database file that has a couple test users, realms, apps, etc.
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.6</version>
<configuration>
<container>
<containerId>wildfly8x</containerId>
<!-- <log>${basedir}/target/cargo.log</log> -->
<!-- <output>${basedir}/target/wildfly.log</output> -->
<home>${project.basedir}/target/cargo/installs/keycloak-appliance-dist-all-1.0.4.Final/keycloak-appliance-dist-all-1.0.4.Final/keycloak</home>
<artifactInstaller>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-appliance-dist-all</artifactId>
<version>1.0.4.Final</version>
</artifactInstaller>
</container>
<configuration>
<properties>
<cargo.servlet.port>8080</cargo.servlet.port>
<cargo.servlet.users>root:root:ManagementRealm</cargo.servlet.users>
<cargo.jboss.configuration>standalone</cargo.jboss.configuration>
</properties>
<files>
<file>
<file>${project.basedir}/WildflyKeycoakConfigs/keycloak.h2.db</file>
<todir>/data</todir>
</file>
</files>
</configuration>
</configuration>
</plugin>

Nuget package restore not respecting my repository path configuration?

I have the following setup in my solution's .nuget/Nuget.Config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
<config>
<add key="repositoryPath" value="C:\Xos\packages\" />
</config>
</configuration>
The point of this is to try and make Nuget package restore manageable, and share packages across our many solutions. I then went into my current solution's packages directory and deleted all the packages (so they would instead restore them to C:\Xos\packages). I then closed VS 2012 and reloaded the solution and rebuilt.
However, all my packages are being restored in my solution's packages directory, NOT the directory specified in repositoryPath configuration.
What am I doing wrong?
I had the same issue with VS2015 RC. One of two things suddenly made it work:
(1) I checked-out the project file from source control, and completely closed Visual Studio (not just the solution).
(2) I edited the csproj file and noticed that the entry for packages.config had a <SubType>Designer</SubType> inner tag, which I removed.
I suspect it was the close-down of Visual Studio...
This appears to be a bug and is fixed in 2.3 (which doesn't appear to be released yet).
Until then I modified my Nuget.Targets as described in that bug and using that for now.