我尝试使用服务定义文件中的 SourceDirectory 功能首先将“Base”目录的内容复制到 Web 角色中,然后将“AdditionalFiles”的内容复制到 Web 角色中。这对于在 Azure 中进行调试效果很好,但是,在打包解决方案时,如果附加文件文件夹包含与基本目录中位置相同的文件,我会在打包解决方案时收到“拒绝访问”错误。
Error 7 Access to the path 'C:\Users\Alex\AppData\Local\Temp\vo0niiyx.rvt\roles\TestWebRole1\approot\connectionStrings.config' is denied. C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Windows Azure Tools\1.5\Microsoft.WindowsAzure.targets 2
为了说明这一点,我正在努力将现有应用程序迁移到 Azure 中运行。我要做的第一步是简单地包装现有功能,以便它可以在 azure 中运行。此外,原始代码库正在快速变化,因此我希望保持我的包装自定义非常独立,以避免不断处理合并等问题。到目前为止,我一直在通过一些复杂的 powershell 构建脚本来处理这个问题。
作为引用,下面是我正在使用的 ServiceDefinition 文件以及我的解决方案的目录结构。我在使用辅助角色时也遇到了同样的问题。
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="AzureSourceDirectoryTest" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
<WebRole name="TestWebRole1" vmsize="ExtraSmall">
<Contents>
<Content destination=".">
<SourceDirectory path="../Base" />
</Content>
<Content destination=".">
<SourceDirectory path="../AdditionalFiles" />
</Content>
</Contents>
<Endpoints>
<InputEndpoint protocol="http" port="80" name="Http" />
</Endpoints>
</WebRole>
</ServiceDefinition>
目录结构(基于tree命令的输出,删除了bin和obj文件夹的内容):
│ AzureSourceDirectoryTest.sln
│
├───AdditionalFiles
│ connectionStrings.config
│
├───AzureSourceDirectoryTest
│ │ AzureSourceDirectoryTest.ccproj
│ │ AzureSourceDirectoryTest.ccproj.user
│ │ ServiceConfiguration.Cloud.cscfg
│ │ ServiceConfiguration.Local.cscfg
│ │ ServiceDefinition.build.csdef
│ │ ServiceDefinition.csdef
│ ├───bin...
│ └───obj...
│
├───Base
│ connectionStrings.config
│
└───TestWebRole1
│ TestWebRole1.csproj
│ TestWebRole1.csproj.user
│
├───bin...
├───obj...
└───Properties
AssemblyInfo.cs
最佳答案
我不确定这应该做什么。实际上应该包含哪个connectionStrings.config?我的猜测是它是同时从两个不同位置复制的,其中一个位置由于并发访问而失败。我能问一下为什么你要复制同一个文件两次吗?
关于azure - 如果 Content SourceDirectory 包含类似文件,则打包 Azure 项目时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7927557/