Web.config file for the contents and Scripts folder not copied while doing an msbuild to get the build package - asp.net-mvc-2

I am working on a asp.net mvc2 project which has Contents folder containing images,css files and Scripts folder containing all the js libraries and files used in the project. I have a web.config file containing the code for enabling caching for the contents present within the Contents and Scripts folder as mentioned below:
Web.config:
<?xml version="1.0"?>
<configuration>
<system.webServer>
<!--Caching-->
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" cacheControlCustom="must-revalidate"/>
<!--<clientCache cacheControlMode="UseExpires" httpExpires="Tue, 31 Dec 2030 12:00:00 GMT"/>-->
</staticContent>
</system.webServer>
</configuration>
I am using msbuild to get a package ready for deployment. I see the package is built successfully containing the MSI which I install in the server. After installing the MSI I see that there is no web.config present within the Contents and Scripts folder in the server.
I tried setting Copy to Output Directory = Copy Always in the properties section of the web.config file but still I don't see it in the Contents and Scripts folder in the server.
Can anyone help me to fix the issue?
Thanks & Regards,
Santosh Kumar Patro

From your question I assume you are building your MSI with the Visual Studio Web Setup Project. In that case, you also need to make sure your extra web.config files are included in the "File System" tab view of your installer project. Normally those would be part of "Content Files".

Related

Output Directory of native dll bundled with NuGet

I am trying to build a NuGet package that includes native DLLs which are to be placed in the output folder when a project uses the package. I have tried to use the several suggestions from this question, but I am always running in the same problem.
My current NuGet package layout is like this:
\build
packageId.targets
file1.dll
file2.dll
\lib
\netstandard1.4
assembly.dll
The contents of packageId.targets is:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<NativeLibs Include="$(MSBuildThisFileDirectory)\*.dll"/>
<None Include="#(NativeLibs)" Link="$(RecursiveDir)$(Filename)$(Extension)">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
This should, according to the answers of the other questions, lead to my DLLs being placed in the bin\Debug directory of the project using the package. However, they are not. Instead, they are placed in bin\Debug\packages\packageId\build.
Now I have experimented a lot, and I noticed more and more strange behavior which I cannot make any sense of:
If I move the DLLs to the root of the NuGet package (like one answer suggests) and change the .targets file accordingly, they are not copied at all. There also is no error message.
If I change the .targets file to only reference file1.dll in both Include= and Link=, both files get copied anyway.
So I wondered if some policy just ignores the .targets file and copies whatever is in build to that path in the output folder, but when I remove the .targets file, the DLL files will not get copied anymore.
Now I understand even less what's happening.
What do I need to change to get the DLLs copied right into bin\Debug?
The new way to handle runtime-specific assents in NuGet is to use the runtimes folder to place native assets:
\lib
\netstandard2.0
ManagedWrapper.dll
\runtimes
\win-x86
\native
NativeThing.dll
\win-x64
\native
NativeThing.dll
\linux-x64
\native
libNativeThing.so
\osx-x64
\native
libNativeThing.dylib
If the package is consumed from a .NET Framework project, you may need to add a reference to the Microsoft.NETCore.Platforms package wich provides the runtime graph (runtimes.json) for NuGet to provide proper RID mappings if you don't use base RIDs (e.g. win10-x64 falls back to win-x64 resources).

Can't specify nuget package folder location [duplicate]

We use a custom location for our packages folder which we specify in a nuget.config file in the same folder as our solution:
<settings>
<repositoryPath>..\..\lib\packages</repositoryPath>
</settings>
Visual Studio 2013 picks this up fine and the NuGet package manager installs packages into the specified folder, lists installed packages correctly, etc.
In Visual Studio 2015 RC the NuGet package manager pops up the "Some packages are missing from this solution, click here to restore" message and if I click the button it creates a new packages folder in the same folder as the solution rather than using the location specified in the nuget.config. Installing a completely new package also puts it into a packages folder under the solution folder rather than the specified one.
How do I get Visual Studio 2015 RC to respect the repository path specified in the nuget.config?
Make sure your nuget.config is configured like this:
<configuration>
<config>
<add key="repositoryPath" value="..\..\lib\packages" />
</config>
</configuration>
I filed this bug with NuGet: https://github.com/NuGet/Home/issues/626
A fix has been made but I'm not sure when it will be released.

No connection string could be found in the application config file (But it Does Exist)

I have a web API project I published to IIS and it complains there is no connection string with a specific name in my config file. I verified there is an entry in my web.config file of the web API project so it must not be picking it up. I was able to run this same web.config file locally using Visual Studio 2013.
I am well aware the referenced start up project must have the connection string and that is the case for me. I verified my web API project has the connection string below (same one I used successfully on my local machine).
<connectionStrings>
<add name="MyDB" connectionString="metadata=res://*/MyDB.csdl|res://*/MyDB.ssdl|res://*/MyDB.msl;provider=System.Data.SqlClient;provider connection string="data source=localhost\MyDB;initial catalog=MyDB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient"/>
</connectionStrings>
Is it complaining about another config file somewhere else on the server?
I already tried the suggestions in this question with no luck.
If your project is published in a folder on IIS, and a config file exists in an uppermost folder, those values may be conflicting.
If another config file exists, try enabling the option "Remove additional files at destination" when publishing. This option is location under Settings -> File Publish Options
Inside bin there is only one web.config file -
Your web.config file should be in same folder as Global.asax, packages.config and not in bin folder.

Change path of a NuGet package

I have a problem with HtmlAgilityPack. I found solution to that problem which is changing reference to another assembly (Why can't I use htmlagilitypack with windows phone 8? What else can I use to Parse HTML in WP8?).
The problem I have that I cannot change path of the package as it is greyed out. The picture bellow shows it.
It's now possible to control which folder the packages are installed into.
http://nuget.codeplex.com/workitem/215
See Phil Haack's comment on Dec 10 2010 at 11:45 PM (in the work item/the link above). The support is partially implemented in 1.0, but is not documented.
According to #dfowler: Add a nuget.config file next to the solution with this:
{some path here}
There is a nuget package for creating the package folder override.
Update for version 2.1
There is now official documentation on how to control the package locations. The release notes for 2.1 specifies the following configuration in a nuget.config file (see the release notes for a description of valid places to put the config files and how the hierarchical configuration model works):
<configuration>
<config>
<add key="repositoryPath" value="C:\thePathToMyPackagesFolder" />
</config>
...
</configuration>
This would change the packages folder for the configuration level you put the file in (solution if you put it in the solution directory, project in project directory and so on). Note that the release notes state:
If you have an existing packages folder underneath your solution root, you will need to delete it before NuGet will place packages in the new location.

How can a NuGet package include transformations for both app.config and web.config?

I'm trying to create a nuget package which will both add a DLL and configure it inside of the proper configuration file. The package can be used in either a console/form application or a web application, so I want to update the appropriate configuration file, either app.config or web.config.
My files section in the .nuspec file contains the following inside of the section.
<file src="config.transform" target="content\app.config.transform"/>
<file src="config.transform" target="content\web.config.transform"/>
The .nupkg file does contain both of the transforms inside of the content folder.
When I add my package to a project in VS2010 through Manage NuGet Packages, the only file which is ever modified is the app.config file. Web.config is never touched. In fact, in a web application with an existing web config, NuGet will create an app.config file which contains the modifications.
Is there a way of doing what I'm trying to do (and if so, how)?
According to a related bug report, it should already work how you want it to. Are you running the latest version of NuGet?