将其他内容文件夹添加到Azure包
Im使用Azure SDK 2.5 我在云服务项目中担任web角色。我想以某种方式添加一个文件夹,以便将其部署在Approt的父目录中。我还没有找到这样做的方法,这让我想知道在csdef中定义虚拟目录的功能有什么用 所以我想我会尝试通过csdef中的Contents/contentXML配置添加文件夹。我要么从根本上误解了这个配置的功能,要么就彻底崩溃了 假定此文件夹结构将其他内容文件夹添加到Azure包,azure,azure-sdk-.net,cspack,Azure,Azure Sdk .net,Cspack,Im使用Azure SDK 2.5 我在云服务项目中担任web角色。我想以某种方式添加一个文件夹,以便将其部署在Approt的父目录中。我还没有找到这样做的方法,这让我想知道在csdef中定义虚拟目录的功能有什么用 所以我想我会尝试通过csdef中的Contents/contentXML配置添加文件夹。我要么从根本上误解了这个配置的功能,要么就彻底崩溃了 假定此文件夹结构 / /CloudService /SomeOtherContent 如果我定义以下内容: <Co
/
/CloudService
/SomeOtherContent
如果我定义以下内容:
<Contents>
<Content destination="frontend">
<SourceDirectory path="..\SomeOtherContent" />
</Content>
</Contents>
我得到:
错误CloudServices089:找不到源目录
'C:\src\template\src\template.CloudService\bin\Debug\..\SomeOtherContent'
好的,现在开始bin\Debug,所以我会让它成为其他内容
错误CloudServices089:找不到源目录
'C:\src\template\src\template.CloudService\..\..\..\..\SomeOtherContent'
是的,没错,解析相对路径的文件夹已更改!!!它不再是bin\Debug。世界跆拳道联盟!?如何才能使其发挥作用?如果输入全驱动器限定的绝对路径,它就会工作。因此,我通过让MSBuild解析路径并将其推入一个名为FrontendDir的环境变量来解决这个问题
<Contents>
<Content destination="frontend">
<SourceDirectory path="%FrontendDir%" />
</Content>
</Contents>
在ccproj中,我补充道:
<UsingTask
TaskName="SetEnvironmentVariableTask"
TaskFactory="CodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v$(MSBuildToolsVersion).dll">
<ParameterGroup>
<Name ParameterType="System.String" Required="true" />
<Value ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Using Namespace="System" />
<Code Type="Fragment" Language="cs">
<![CDATA[
Environment.SetEnvironmentVariable(Name, Value);
]]>
</Code>
</Task>
</UsingTask>
<Target Name="BeforeBuild" Condition=" '$(FrontendDir)' == '' ">
<Message Text="Setting Project Dir" Importance="high" />
<SetEnvironmentVariableTask Name="FrontendDir" Value="$(ProjectDir)\..\Template.FrontEnd\dist" />
</Target>
最好在这里将整个路径放入env变量中,因为您可以在不同的构建场景中通过重写值轻松地重写它,例如/p:FrontendDir=c:\foo
所以这很有效,而且效果相当好。我仍然说我以前看到的相对路径分辨率改变文件夹的行为是。。。破碎的它无法以任何可用的方式处理相对路径。您看到的是相同的错误,但来自不同的msbuild目标 使用..\..\时的第一个错误是在PreValidateServiceModel上引发的,它将传入源位置并检查路径
ServiceDefinitionFile="@(SourceServiceDefinition)"
ServiceConfigurationFile="@(SourceServiceConfiguration)"
C:\src\Azure\ServiceDefinition.csdef:错误CloudServices089:无法
在角色中查找源目录“C:\src\Azure\..\..\..\Installers\”
网络主机。[C:\src\Azure\Azure.ccproj]
已完成在Azure.ccproj项目中构建目标PreValidateServiceModel-失败
第二个错误是在传递到目标位置的ValidateServiceFiles上引发的
ServiceDefinitionFile="@(TargetServiceDefinition)"
ServiceConfigurationFile="@(TargetServiceConfiguration)">
C:\src\Azure\bin\Release\ServiceDefinition.csdef:错误CloudServices089:无法
查找源目录
'C:\src\Azure\bin\Release\Installers'
在角色WebHost中。[C:\src\Azure\Azure.ccproj]
已完成在project Azure.ccproj中构建目标ValidateService文件-失败
如果您考虑C:\Program Files\Microsoft SDK\Azure.NET SDK\v2.9\bin\ServiceDescription.dll,您可以看到ProcessRoleContents方法执行验证,但使用SourceFile解析位置
一个选项是确保目标文件夹存在,即使在构建开始之前是空的
如果预验证解析了路径,并且保存目标时,它具有完整路径,则会更好
我最终编辑了ccproj,并添加了这个
<Target Name="BeforeAddRoleContent">
<ItemGroup>
<AzureRoleContent Include="Installers\">
<RoleName>Azure</RoleName>
<Destination></Destination>
</AzureRoleContent>
</ItemGroup>
</Target>
如果你去乔治亚州,我欠你一杯啤酒。。还有一个拥抱!谢谢,这非常有用。哈哈,太棒了。必须检查你的个人资料以确保你不是指前苏联格鲁吉亚