-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IIS -> Lock .NET Core application DLL file #3793
Comments
If you end up desiring a PowerShell way of doing it, you can use the IIS Admin cmdlets: https://technet.microsoft.com/en-us/library/ee790599.aspx
|
Can you make it to 'just work' with msdeploy.exe and Azure? If I understand correctly the web site needs to be restarted to prevent file locking. |
@chuchuva maybe, but all magic comes with a cost. Previous versions of ASP.NET did some complicated shadow copying to work around the file locking problems. |
Magic or not, It worked well. I kinda miss it now after the migration to ASP.NET core... |
Agreed with @HarelM. We've run into issues with this from our automated deployments to just end user experience. We've gone from deploying about 10 times a day with the old MVC to maybe a daily deployment at night and accepting that the people using the Core app are going to be annoyed when we take it offline. While not a show stopper, it's added friction towards Core adoption. |
👍 Not supporting overlapped recycling is a regression. |
Are there plans to revisit this feature and put it on the road map? It's very inconvenient/unfriendly to require everybody deploying a .Net Core website to manually implement a staging-slot strategy if they want to support zero downtime deployments. Having this feature would make the transition to .Net Core websites much smoother for many people, and would allow for faster adoption of .Net Core websites. |
We would like to know as well. Putting a app_offline.htm inside the applications directory does not work. |
I've only just realised this 'feature' after moving a number of sites over to AspNetCore. I can't believe it's deemed to be acceptable to take your sites offline for a few minutes every time you want to publish! This is bad enough for me as a leader of a small team - are those practicing continuous integration on a large scale shunning AspNetCore? There is no way they would be able to have their site going offline for minutes every hour to republish! |
Are you deploying use FTP or xcopying? Or are you using webdeploy? |
I'm publishing via webdeploy to IIS. |
We are currently working around this issue by just deleting the web.config first (effectively killing the application), but this is not really an acceptable solution in the long run. @DaleMckeown ideally with a continuous integration workflow you'd have multiple servers behind a load balancer. You'd then pull one server, update it, put it back en move on to the next. Ofcourse this is not always possible (like in our case), so you'll have to live with a few minutes downtime. In our case the app is back up within 30s, so this is not really an issue. |
There are a few options that can be used to make deployment using webdeploy work well (it supports renaming locked files and dropping app offline automatically). Is that the case by default @shirhatti ?
Does that mean you're doing xcopy deployment? |
Thanks David - sounds better than what I am currently doing (manually stopping the site & app pool in IIS). Can you point to some resources so I can investigate the implications of these approaches? |
@DaleMckeown some info untilI find the source of truth microsoft/azure-pipelines-tasks#5259 (comment) |
@davidfowl We're using webdeploy to deploy to our testserver (which btw never gives us problems), from there we copy the files to our live servers using robocopy |
When the web.config is removed from the deployment, IIS will serve sensitive files from the deployment. An attacker could simply request files continuously day and night until your 30s window opens up. Following @ajeckmans advice if you ever want to get into the weeds a bit with a PS approach to do that, you can script the process to drop AppPools one at a time for deployment across a web farm. For an example of how that can be done, see https://github.com/guardrex/aspnetcore-iis-ps-publish ... but just look at that as an experimental example and not a production-quality script. I haven't played with that for a while, but it should (in theory) still work. |
@guardrex you're right. We copy an app_offline.htm to the dir first, then we remive the web.config, copy over the application, put back the web.config and remove the app_offline (all with a script ofc). Unfortunately just placing the app_offline file in the websites directory does not break the lock on the dlls. We need to remove the web.config, an action we don't need to do for the older asp.net full apps (like old webforms etc) |
@ajeckmans That shouldn't work. When the web.config file is removed, IIS picks that change up immediately, so it should default requests over to the Static File Module and start serving files. Try it and see if that's what happens ...
I wouldn't trust merely removing module with ... <configuration>
<system.webServer>
<modules>
<remove name="StaticFileModule" />
</modules>
</system.webServer>
</configuration> ... since other modules would remain and possibly present other attack vectors. Maybe one could remove all of the non-essential modules, but we're getting into uncharted waters with a move like that just to cover a deployment via removal of web.config. That's never been an option under the official guidance, and so it's completely unsupported. I recommend PS scripting, for example, to take the AppPool down, or some other strategy. |
I guess I should add a note of sympathy to that ... it did raise a few eyebrows from a security perspective. When that deployment layout change was made, it was discussed, including putting the file back into Discussion for: Publish for IIS changes to web.config location (IISIntegration 158) [EDIT] Perhaps that's your (unsupported) workaround: Move the web.config back to wwwroot, then go ahead with what ur doing. Still tho ... kind'a scary breaking the app to get it offline like that. |
This leaves me even more confused about what we should be doing in this situation. What's the current recommendation for publishing AspNetCore sites to IIS via web deploy in a way that can avoid file locks? |
I would like to know as well. This is becoming a major roadblock to .net core adoption at my organization. |
When my .net core web application is running and I am trying to publish a new build, it gives me error that DLLs are in use. So I have to Stop the app pool, then update the DLLs and start the App Pool. Is there any workaround in .Net Core by which I can publish the new Build/DLLs without stopping the App Pool ? This is by default supported in .Net framework using shadow copy mechanism. Unfortunately, It's been 2 years since the launch of .Net core and seems like there's still no support for such very basic and required functionality. Is there even any plans to fix this in future ? Thanks in advance for any help. |
@guardrex it is indeed scary to break the app to get IIS (or whatever is holding the lock) to release the dll's, however it is even scarier to not be able to push hotfixes to a product. For the time being breaking the app is the only thing we can do, but we're ofc looking into other more modern approaches to handling this :) @shahjay748 don't hold your breath. If I were te redo the process here, I'd put the app inside a container and just put up a new container and switch traffic and pull the old version down (or something like that). It seems like the more sane thing to do and seeing as .net core is all about new modern ways, just pushing a new version of the app by simply copying over the new files is considered (and I agree) a bit of an arcane way to do it. |
What i do (Not sure if it's a proper way of doing it), is upload the site to another directory and switch paths in iis |
We did some internal investigation on this issue. From what I can tell, ANCM does not hold any files/handles in the deployed application. It seems to be an issue with webdeploy itself, and it flakily fails deployment. I never had it consistently fail to deploy the application after retrying a few times once app_offline was dropped. |
Any news? I really expect this. |
Thank you for contacting us. Due to a lack of activity on this discussion issue we're closing it in an effort to keep our backlog clean. If you believe there is a concern related to the ASP.NET Core framework, which hasn't been addressed yet, please file a new issue. This issue will be locked after 30 more days of inactivity. If you still wish to discuss this subject after then, please create a new issue! |
lol @msftbot you're doing more harm than good. |
Bad @msftbot ! |
|
The shadow copying in IIS has been a beta feature for 4 months now (since preview 3) https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-6-preview-3/#shadow-copying-in-iis How has feedback / testing been? Any word / commitments on if it'll be included as a (non-experimental) feature in .NET 6 final this fall? |
There has been almost no feedback on the feature so far. Since we're now at the RC1 deadline we're planning to leave it as experimental for this release in hopes of getting more feedback. |
Hello @jkotalik, I've just used shadow copy feature. I am not sure if I am doing it right. But from first time I was using dotnet core I was trying to set dev environment to work similar to what I've experienced with old asp.net. Today I read about that shadowcopy feature and got really excited to try it. I've installed new hosting bundle and tried to run it with application using net core 3.1. I can see in logs that shadow copy kicks in (it created new folder with copy of the whole web project contents). But the problem is that I am still getting the same locking error during build if applicaiton is still running Am I using it wrong? I couldn't find any end to end example how it should work and what is the expected behaviour. Any advice appreciated :) |
Hello again. I've spent some more time to check if I am not doing something wrong.
And on both configurations bahaviour was the same. It was as follows:
It is not what I would expect. Especially after reading Looking forward for your reply :) |
@jgasiorowski what versions of asp.net core are you using, and what does your web.config look like for the app after publish? |
@HaoK I was trying that for two versions
|
@jgasiorowski try turning on the debugFile and level and you should see things like:
When you say you try to delete the bin directory, have you tried just deleting the test1.dll instead of the entire directory to see if your app dll is still locked? |
Please test 6.0 as well. I don't know if this feature is intended to work with prior versions. |
@HaoK Full log looks like that
Yes I tried delete whole directory. I checked just now if I can delete only the @Tratcher I will try it soon since I don't have sdk for net 6 installed. I've installed only hosting bundle to have iis module available. I will return with the answer. But Based on module code and behaviour it really looks like the wrong path is being locked |
@Tratcher I tried with I have to say that I am sad that it does not work for .net version lower than 6. My preferred environment is to work with services which communicate with normal domain names instead of Is there any chance that this feature will support older versions of .net? Update: I have checked PR #28357 and I couldn't find any sign of check whether application runs under |
As a rule we do not add features to older versions, it risks destabilizing existing apps.
I recall a change was required in the underlying runtime to allow us to load dlls from a different location. I'd have to dig into the details to confirm which change that was. However, supporting older versions is a non-goal so debugging them isn't a priority. |
@Tratcher Thanks for the answer. But is that a valid point to raise an issue related with shadow copy not working correctly when working on not published website? |
I wasn't addressing your un-published scenario, I was talking only about your ask for support in prior versions. I don't think this was designed with un-published scenarios in mind since they have a significantly different layout and workflow. The Visual Studio flow with IIS Express is specifically designed for un-published apps. |
I know, sorry my previous comment wasn't formatted correctly - I meant just a question if that would be valid if I would raise an issue about development-time support for shadow copy. |
Hi. I just want to say thank you for adding this. This made my life much easier. This feature has been working great for me since its appearance in previews @jkotalik |
@joelmandell Introduced in VS2022? |
@joelmandell Can you details the steps you did to enable it, and how you deploy now that you got it working? EDIT - Related docs issue - dotnet/AspNetCore.Docs#23733 |
Thank you for contacting us. Due to a lack of activity on this discussion issue we're closing it in an effort to keep our backlog clean. If you believe there is a concern related to the ASP.NET Core framework, which hasn't been addressed yet, please file a new issue. This issue will be locked after 30 more days of inactivity. If you still wish to discuss this subject after then, please create a new issue! |
When I try to overwrite .NET Core application DLL file using FTP on production IIS server file is locked and it cannot be overwritten.
To deploy new version I need to stop application in IIS to release lock, then overwrite.
It is not possible to deploy without stopping application.
The text was updated successfully, but these errors were encountered: