如何确定\\临时ASP.NET文件\\ ROOT \\ {网站哈希}使用PowerShell? [英] How to determine the \Temporary ASP.NET Files\root\{site hash} with PowerShell?

查看:207
本文介绍了如何确定\\临时ASP.NET文件\\ ROOT \\ {网站哈希}使用PowerShell?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ASP.NET使用了一个临时文件目录来存储阴影复制和动态编译文件。一个典型的路径是这样的。注意在路径的结尾哈希值。

  C:\\ WINDOWS \\ Microsoft.NET \\框架\\ v4.0.30319 \\临时ASP.NET文件\\ ROOT \\ {}哈希

我使用自动部署,并已注意到,这些文件夹及其内容不会被自动删除。我想自动删除未使用的临时文件作为我的部署过程的一部分的过程。例如,一旦我的网站的新版本部署旧的临时文件被删除。

哈希看起来那么我希望我能确定的哈希作为我的pre-部署脚本的一部分,并删除它部署后,以以确定的方式产生。

散是如何计算的ASP.NET网站?

参考文献:


  1. How .NET名C内的临时文件夹:\\ WINDOWS \\ Microsoft.NET \\框架\\ V {版本} \\临时ASP.NET文件\\根

  2. http://blogs.msdn.com/ b /俊峰/存档/ 2004/02/09 / 69919.aspx

  3. http://dotnetinside.com/en/type/System。网络/ ApplicationManager / 4.0.0.0


解决方案

好了,一会儿带反射,搜索范围内的System.Web所有成员的词临时表示该电话让我在这里:

 字符串STR2 = AppManagerAppDomainFactory.ConstructSimpleAppName(AppDomainAppVirtualPath);

但后来我记得源$ C ​​$ c是适用于所有的.NET,所以我移动到实际code,而不是reflectored code:的http://referencesource.microsoft.com/#System.Web/xsp/system/Web/HttpRuntime.cs#872

后来在该方法中的设置codeGenDirectory的路径似乎是在上方内置有

 此._ codegenDir = Thread.GetDomain()DynamicDirectory。

所以,看起来像哈希是DynamicDirectory。这是在这里 http://referencesource.microsoft.com/#mscorlib/system /appdomain.cs#2792 它看起来像一个外部的是里面的一些COM融合装载机的东西:

  [ComImport,InterfaceType(ComInterfaceType.InterfaceIsIUnknown)的Guid(7c23ff90-33af-11d3-95da-00a024a85b51)]

但是,GUID导致我在这里 http://referencesource.microsoft .COM /#mscorlib程序/微软/的Win32 / fusionwrap.cs#94

这意味着它是一个公钥标记部分:

 公共常量UINT HASH_VALUE = PUBLIC_KEY_TOKEN + 1;
     公共常量UINT NAME = HASH_VALUE + 1;

这或许是它的名字?我猜这是 yourAssembly.GetPublicKeyToken();

OR,只是改变你的ASP.NET临时文件转到配置部分<一个文件夹href=\"http://msdn.microsoft.com/en-us/library/system.web.configuration.compilationsection.tempdirectory%28VS.80%29.aspx\" rel=\"nofollow\">http://msdn.microsoft.com/en-us/library/system.web.configuration.compilationsection.tempdirectory%28VS.80%29.aspx在web.config中的System.Web

 &LT;编译tempDirectory =D:\\ MoveThemHere&GT;

ASP.NET makes use of a temporary files directory to store files for Shadow Copying and Dynamic Compilation. A typical path will look like this. Note the hash on the end of the path.

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\{hash}

I'm using automated deployments and have noticed that these folders and their contents are not automatically removed. I'd like to automate the process of removing unused temp files as part of my deployment process. Such that as soon as the new version of my site is deployed the old temp files are removed.

The hash seems to be generated in a deterministic manner so I'm hoping I'll be able to determine the hash as part of my pre-deployment script and delete it post-deployment.

How is the hash calculated for an ASP.NET website?

References:

  1. How .Net names its temp folder inside C:\Windows\Microsoft.NET\Framework\v{version}\Temporary ASP.NET Files\root
  2. http://blogs.msdn.com/b/junfeng/archive/2004/02/09/69919.aspx
  3. http://dotnetinside.com/en/type/System.Web/ApplicationManager/4.0.0.0

解决方案

Well, a few moments with Reflector, searching all members within System.Web for the word "Temporary" shows this call gets me here:

string str2 = AppManagerAppDomainFactory.ConstructSimpleAppName(AppDomainAppVirtualPath);

But then I remember that the source code is available for all of .NET, so I move to the actual code, rather than the reflectored code: http://referencesource.microsoft.com/#System.Web/xsp/system/Web/HttpRuntime.cs#872

Later in that method "SetupCodeGenDirectory" the path appears to be built on top of with

 this._codegenDir = Thread.GetDomain().DynamicDirectory;

So, looks like that hash is from DynamicDirectory. That's over here at http://referencesource.microsoft.com/#mscorlib/system/appdomain.cs#2792 which looks like an extern that is inside some COM Fusion Loader stuff:

[ComImport,InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("7c23ff90-33af-11d3-95da-00a024a85b51")]

But that GUID leads me here http://referencesource.microsoft.com/#mscorlib/microsoft/win32/fusionwrap.cs#94

which implies it's a public key token part:

     public const uint HASH_VALUE            = PUBLIC_KEY_TOKEN + 1;
     public const uint NAME                  = HASH_VALUE + 1;

That perhaps it's NAME? I'm guessing it's yourAssembly.GetPublicKeyToken();

OR, just change the folder that your temporary ASP.NET files go to in config section http://msdn.microsoft.com/en-us/library/system.web.configuration.compilationsection.tempdirectory%28VS.80%29.aspx in system.web in web.config

<compilation tempDirectory="D:\MoveThemHere">

这篇关于如何确定\\临时ASP.NET文件\\ ROOT \\ {网站哈希}使用PowerShell?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆