Asp .Net Core Fail to delete file during publish using File System - asp.net-core

I am deploying to IIS using file system but i get error on deleting the current dll files on iis folder.
I read that the app needs to add the app_offline.html file to do this and that i need to add
<WebPublishMethod>FileSystem</WebPublishMethod>
<EnableMSDeployAppOffline>True</EnableMSDeployAppOffline>
somewhere when using filesystem. I can't find any information about this tho, i tried doing it on csproj file but no luck.

The <EnableMSDeployAppOffline> requires Web Deploy. If you're doing a filesystem publish, it's not going to have any effect. You need to either publish via Web Deploy, or manually stop the App Pool, move the files, and then start it up again.

Related

Where is Web.config during development?

When I publish my ASP .Net Core 1.1 MVC web app, I see the Publish folder contain a Web.config file, where I can set stdoutLogEnabled, etc. However, while developing I don't see this file at all - it looks like it's being generated when publishing... How can I therefore set the variables in this file without having to manually edit the file after each publish?
Web.config only makes sense if you host the app on Windows with IIS. You have to manually add it to the project to edit the file's contents or it will be auto-generated:
Documentation:
If you don't have a web.config file in the project when you publish with dotnet publish or with Visual Studio publish, the file is created for you in published output. If you have the file in your project, it's transformed with the correct processPath and arguments to configure the ASP.NET Core Module and moved to published output. The transformation doesn't touch IIS configuration settings that you've included in the file.

MsBuild Web deploy ERROR_FILE_IN_USE

I have a TFS build using Web Deploy to publish changes to a high traffic website. Build places an AppOffline.htm when it starts. A lot of times build fails due to some dll file in use. Tried recycling app pool and stating/stop website before build, still fails.
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.targets (4255): Web deployment task failed. (The file 'xxx.dll' is in use.
Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_FILE_IN_USE.)
Only way to publish successfully is to stop the website for whole duration while publish is going on.
Check for any files marked read only.
Some have said anti-virus can occasional cause this error as well. Try ignoring your web files.
I'm also seeing an issue where a VS2015 Web Publish to an Azure Web App has recently started to throw an error advising that a DLL file is locked...
See
https://github.com/Microsoft/vsts-tasks/issues/1607#issuecomment-272504519

Deploying external files from visual studio with .NET CF application

I am working on a .NET CF 3.5 application. There are few external files\assemblies that the application is consuming. These files are not part of the project, therefore while debugging when I deploy the project, these external files are not deployed to the device.
Is there any way I can deploy these files with project without including them in the project?
You can't get Studio to deploy arbitrary files without telling it what files to deploy. The only way to tell Studio to deploy files is to either add the files to the project (as a Resource or a Content file) or by adding a reference to them (for .NET assemblies).

How to create Web Deployment Package for IIS WebSite and use standard manifest/parameters

I have various IIS hosted service hosts with simple svc files etc. What I want to do is to be able to create deployment packages from our test server using IIS Export Package in a way that parameters may be saved and picked up at Export time so that the Export is repeatable and automatable. I.e. the Export will always use the necessary Manifest extensions such as XmlFile etc.
The web sites exist in the solutions and are then picked up using a Web Deployment project in each solution so that config substitutions are done etc.
We are currently on VS 2008 SP1 so do not have direct access to VS 2010
The first issue I have with MsBuild (running in TeamCity) is how to build the IIS web site (with target=Package) when there is no project file? In this way maybe I can avoid the Web Deployment projects (I use them for various configurations but don't want to do it this way for deploying to Production but rather export from our fully tested staging into a package file to be imported onto a production server).
Secondly, I want to avoid having to configure the Export in IIS 7 each time I run it. I want it simply to pick up the correct set of extensions to use and create the necessary parameters for me. Is this done from a Manifest file? I can see how to use the parameters.xml but I am unclear whether I need to use a manifest.xml (created by hand) and how to link it in. The idea is that a tester/deployment person should be able to do the Export simply without having to enable all of the extensions that are required
Any help or guidance will be greatly appreciated.
Ok, in the meantime I got it figured out.
I ended up using the document at Package an Application for the Windows Web Application Gallery which gave me the means by which I could extend our automated build in TeamCity to create the "repeatable" export packages.
In short I will use the current Web Deployment Projects to create the deployment artefacts and then in MsBuild combine them with the pre-prepared manifest.xml and parameters.xml files into Build artefacts folder and zip them up into a package. From there the task will be to Import the package into IIS Deploy in the target environment.
The parameters.xml file will be used to set the HostName for wcf clients and services, connection strings, app settings etc.
This turned out to be the best solutuion bcause I can put it into our automated build.

aspnet_client folder within IIS website

I want to know how to permanently remove the aspnet_client folder under some of our websites in IIS.
Our application does not require it, and scripts against these folders fail due to the folder permissions on this folder.
Even the .NET 4 install continues to add this folder. There doesn't seem to be a permanent way to delete the folder, outside of deleting it after registering .NET with IIS, or after installing a new version of the .NET Framework.
Some people say they throw a read-only attribute on the directory, but ... that still keeps the directory hanging about.
See my answer to a similar question, Prevent aspnet_client folder being added to .NET sites
To reiterate that answer:
Check out the MSDN documentation on the ASP.NET IIS Registration Tool (Aspnet_regiis.exe). There's an e and ea command line switch you should be able to use to clean it up after the fact.
You can use Aspnet_regiis.exe to install and remove system client-side script, such as script for client-side validation. Use the -c option to install client script for the version of ASP.NET that is associated with the tool. (Script is installed in the Aspnet_client subdirectory of each IIS site directory.) To remove the client-side script for just the ASP.NET version that is associated with the tool, use the -e option. To remove the client-side script for all installed versions of ASP.NET, use the -ea option.
(Emphasis added.)