将其他内容文件夹添加到Azure程序包 [英] Adding additional content folders to Azure package
问题描述
我正在使用Azure SDK 2.5 我在云服务项目中担任网络角色.我想以某种方式添加一个文件夹,以便将其部署在approot的父目录中.我还没有找到一种执行此操作的方法,这使我想知道在csdef中定义虚拟目录的功能有什么用.
Im using Azure SDK 2.5 I have a web role in a cloud service project. I would like to add a folder in some fashion such that it is deployed in the parent directory of the approot. I havent found a way to do this which kind of makes me wonder what use is the ability to define virtual directories in csdef.
所以我想我会尝试通过csdef中的Contents/Content xml配置添加文件夹.我要么根本上误解了配置的功能,要么无可救药.
So I thought I would try adding folders via the Contents/Content xml config in the csdef. I am either fundamentally misunderstanding what this bit of config does or its hopelessly broken.
假设此文件夹结构
/
/CloudService
/SomeOtherContent
如果我定义以下内容:
<Contents>
<Content destination="frontend">
<SourceDirectory path="..\SomeOtherContent" />
</Content>
</Contents>
构建,我得到:
错误CloudServices089:找不到源目录 'C:\ src \ template \ src \ Template.CloudService \ bin \ Debug \ .. \ SomeOtherContent'
error CloudServices089: Cannot find the source directory 'C:\src\template\src\Template.CloudService\bin\Debug\..\SomeOtherContent'
好吧,它开始了bin \ Debug,所以我将其设置为.. \ .. \ .. \ SomeOtherContent
Ok so its starting the bin\Debug, so I'll just make it ..\..\..\SomeOtherContent
错误CloudServices089:找不到源目录 'C:\ src \ template \ src \ Template.CloudService \ .. \ .. \ .. \ SomeOtherContent'
error CloudServices089: Cannot find the source directory 'C:\src\template\src\Template.CloudService\..\..\..\SomeOtherContent'
是的,我的相对路径所在的文件夹已更改!!!它不再是bin \ Debug. WTF !!如何使它起作用?如果我输入完整的驱动器限定的绝对路径,它将起作用.
Yes thats right, the folder at which my relative path is resolved has changed!!! Its no longer bin\Debug. Wtf!? How can this be made to work? It works if i enter a full drive qualified absolute path.
推荐答案
所以我通过让MSBuild解析路径并将其推送到我称为FrontendDir的环境变量中来解决了这个问题.
So I solved this by having MSBuild resolve the path and push it in to an environment variable which I called FrontendDir.
<Contents>
<Content destination="frontend">
<SourceDirectory path="%FrontendDir%" />
</Content>
</Contents>
,在我添加的ccproj中:
and in the ccproj I added:
<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 var中,因为这样您就可以通过覆盖值(例如/p:FrontendDir ="c:\ foo")在不同的构建方案中轻松覆盖它
Its preferable to put the entire path into the env var here as you can then override it easily in your different build scenarios by overriding the value (eg. /p:FrontendDir="c:\foo")
这样可以正常工作.我仍然说我以前在使用相对路径分辨率更改文件夹时看到的行为是...坏了.它只是无法以任何可用的方式与相对路径一起使用.
So that works and works fairly well. I still say the behaviour I was seeing before with the relative path resolution changing folders is... broken. It just doesn't work with relative paths in any usable way.
这篇关于将其他内容文件夹添加到Azure程序包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!