Deploying Bitbucket to Azure Web Site: add private nuget package server - asp.net-mvc

I have set up a website on Azure to deploy through a Bitbucket repository. The process fails when it tries to install nuget packages which are stored on a private nuget server, not nuget.org. Is there a way to specify where to restore the nuget packages from so that Azure can restore these packages?

You can add a custom NuGet.config file at the same level as your .SLN file.
You can then make the following modifications (assuming that your private feed requires authentication, create a set of credentials which only are used for this site):
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
<packageSources>
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
<add key="custom_package_source" value="https://custom_package_source/nuget/v1/FeedService.svc/" />
</packageSources>
<disabledPackageSources />
<packageSourceCredentials>
<custom_package_source>
<add key="Username" value="CustomUsername" />
<add key="ClearTextPassword" value="CustomPassword" />
</custom_package_source>
</packageSourceCredentials>
When you deploy via Kudu, this should allow the build process to discover your private feed, authenticate & restore your packages.
If you do not require authentication against your private feed, remove the <packageSourceCredentials> element.

Related

Visual Studio 2019 Enterprise automatically adds COMPLUS_ForceENC environment variable while debugging/running using IIS Express

I'm using Visual Studio Enterprise 2019 version 16.3.10. Whenever I run/debug my web project using IIS Express, it adds COMPLUS_ForceENC environment variable as shown below:
<environmentVariable name="COMPLUS_ForceENC" value="1" />
Here is the screen print,
Every time I need to undo this change before committing my changes to source control. Please can anyone assist me on how to avoid this change?
After a long time, I got response from Visual Studio developer community.
The web.config only gets updated if you have the following section present in the web.config. You can remove the following from the web.config and running the application will not update the existing web.config. if you are using IISExpress, You can alternatively remove the full web.config from the project. web.config is not required in the project for running in IISExpress.
<handlers>
<remove name="aspNetCore" />
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess">
<environmentVariables>
<environmentVariable name="ASPNETCORE_HTTPS_PORT" value="44370" />
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
<environmentVariable name="COMPLUS_ForceENC" value="1" />
</environmentVariables>
</aspNetCore>
Here is the link for the same.
Adding this Enivronment Variable seems to be a workaround for enabling the "Edit and Continue" debugger feature.
Source

NuGet.Config file Transforms?

Is there a way to transform a Nuget.Config file in a solution based on the solution configuration? I have one packageSource that I only use for resolving dependencies on my local machine. I don't want this packageSource to be used at all when I build the solution on the build server.
<?xml version="1.0" encoding="utf-8"?>
<packageSources>
<clear />
<add key="MyLocalFeed" value="\\MyNetworkShare" />
<add key="CompanyFeed" value="http://companynugetserver/" />
</packageSources>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
</configuration>
In the above sample Nuget.Config, I only want to use "MyLocalFeed" on my local development server ("Debug" configuration in the solution). Once all changes are checked-in and built on the build server, the "MyLocalFeed" packageSource should no longer appear/be ignored. I have to keep the <clear /> statement in the config, per company requirements.
No, we cannot transform a Nuget.Config file in a solution based on the solution configuration.
Based on your description you can use the "MyLocalFeed" for local development, and remove "MyLocalFeed" in the Nuget.Config file and use that file in TFS build to restore the packages from CompanyFeed.
But please note that the local packages may have other dependencies which are not included in CompanyFeed...
So we recommend using the same NuGet feed for development and CI, or you push all the related packages into theCompanyFeed.

Browser cache for static contents

I am trying to update the configuration which effects the browser caching settings for static resources (js, css, images).
I have Sitecore CMS site and images uploaded in CMS, these images are cached in browser (status code = 200 (from cache), when i observed the network in Chrome browser), but my other resources like js and css which served from Website folder are not cached in browser, and the status code is 304 (which is server cache and there is a round trip required to check for any update.)
I have below config settings in web.config file:
<caching>
<profiles>
<add extension=".jpeg" policy="CacheUntilChange" kernelCachePolicy="DontCache" />
<add extension=".js" policy="CacheUntilChange" kernelCachePolicy="DontCache" />
<add extension=".png" policy="CacheUntilChange" kernelCachePolicy="DontCache" />
<add extension=".jpg" policy="CacheUntilChange" kernelCachePolicy="DontCache" />
<add extension=".css" policy="CacheUntilChange" kernelCachePolicy="DontCache" />
<add extension=".json" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="00:00:30" />
</profiles>
</caching>
<staticContent>
<remove fileExtension=".woff2" />
<mimeMap fileExtension=".json" mimeType="application/json" />
<mimeMap fileExtension=".woff2" mimeType="application/x-font-woff2" />
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" />
</staticContent>
Now if i remove the caching-profiles entry, then the resources are cached in browser, i can see all the css, js status code as 200 (from cache) for the subsequent request.
My question here is, what is the difference here, why browser cache didn't worked even there is a staticContent settings are added. What is the impact if I remove the existing caching-profiles settings (will it impacts server cache?).
I saw some other links, which explains static cache settings, but i want to know the impact with the changes i did (removed caching-profiles)
Please let me know your inputs.
Below are the Response header details:
With caching-profiles:
Without caching-profiles:
Thanks,
Sharath
So, it appears you are configuring IIS output cache for .jpeg, .js, ..., within the web.config system.webServer/caching node (beware, .webServer, not .web).
Unfortunately, IIS output cache (and Asp.Net output cache too by the way) does also handle client caching, and so it interferes (badly) with your client caching settings. (It should be two separate matters in my opinion, but that is not the way IIS/Asp.Net output caches handle it.)
Your profiles do not set the location attribute, so they default to Server. With output cache semantic, this means "no client cache", thus the no-cache it adds in Cache-Control response header.
To avoid this, you may change your profile location to Any.
<profiles>
<add extension=".jpeg" location="Any" policy="CacheUntilChange" kernelCachePolicy="DontCache" />
<add extension=".js" location="Any" policy="CacheUntilChange" kernelCachePolicy="DontCache" />
<add extension=".png" location="Any" policy="CacheUntilChange" kernelCachePolicy="DontCache" />
<add extension=".jpg" location="Any" policy="CacheUntilChange" kernelCachePolicy="DontCache" />
<add extension=".css" location="Any" policy="CacheUntilChange" kernelCachePolicy="DontCache" />
<add extension=".json" location="Any" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="00:00:30" />
</profiles>
But maybe should you simply not use IIS output-cache for .jpeg, .js, ...
From official IIS documentation:
Output caching is unnecessary for static files, such as HTML, JPG, or GIF files, ...
It has no benefit using IIS output cache for static files. (It may have benefits using an actual cache server such as varnish in front of your IIS, but emulating a cache server with IIS output cache has no benefit for static files.)
If you have some special cases URIs endings with static file extension but actually served dynamically by your application instead of directly corresponding to a file on disk (special case usually involving using rammfar which is a bad thing for application scalability; linked page gives some alternates by the way), better try enabling output-cache only for those URIs, by configuring it under
<configuration>
...
<system.webServer>
... <!-- not here! -->
</system.webServer>
...
<location path="yourDynamicImagesUriBasePath">
<system.webServer>
<caching>
... <!-- move it here -->
(I am not sure it works though, better test it of course.)

Automapper Failing when take latest from TFS

My team mate installed AutoMapper latest version in his workstation using
nuget in all the projects whereever referenced in the solution. In
package.config we can see the automapper latest version. It was building
properly in her machine. But when I take latest and run the project in my
machine, the Automapper failed but I can see in packages.config the new
version. But in reference the Automapper is showing not found with an yellow
icon.
It seems that the NuGet Package didn't restored Automapper successfully.
Possible duplicate with this question:TFS Can't Restore NuGet Package
Try to make sure both package sources are added to your NuGet.config file. Also ensure both sources are 'active'.
<configuration>
<packageSources>
<add key="nuget.org"
value="https://www.nuget.org/api/v2/" />
<add key="example.com"
value="http://example.com/feed/nuget/" />
</packageSources>
<activePackageSource>
<add key="All"
value="(Aggregate source)" />
</activePackageSource>
</configuration>

Configure Claim based identity for multiple applications in localhost

I have two applications "http:/localhost/applicationA" and "http:/localhost/applicationB". I have configured applicationA for claim based authentication settings. applicationA is working perfectly. But I am refering some javascrips of applicationB from applicationA. But applicationB has no the authentication cookies(FedAuth).
Is it possible for me to add claim authentication in both applicationA, applicationB using the below code?
<system.identityModel>
<identityConfiguration>
<audienceUris>
<add value="http://localhost/applicationB/" />
<add value="http://localhost/applicationA/" />
</audienceUris>
<issuerNameRegistry type="System.IdentityModel.Tokens.ValidatingIssuerNameRegistry, System.IdentityModel.Tokens.ValidatingIssuerNameRegistry">
<authority name="PassiveSigninSTS">
<keys>
<add thumbprint="DE161DD37B2FEC37BDB17CAFF33D982DCE47E740" />
</keys>
<validIssuers>
<add name="PassiveSigninSTS" />
</validIssuers>
</authority>
</issuerNameRegistry>
<!--certificationValidationMode set to "None" by the the Identity and Access Tool for Visual Studio. For development purposes.-->
<certificateValidation certificateValidationMode="None" />
</identityConfiguration>
You would need to enable claims authentication in applicationB for this to work. In other words, you would need to setup the same system.identityModel web.config settings in applicationB as in applicationA (as you've shown in your example).
Is there a reason that the JavaScript needs to be secured? If the scripts aren't secured, why not just make them accessible to everyone so you won't need to worry about the single sign-on across sites?

Resources