我在Visual Studio 2015中有一个.NET Azure解决方案。该应用程序使用2个辅助角色。
作为其功能的一部分,在构建过程中的某些时刻,会将几个dll复制到云项目中,以便最终得到最终结果。
为了使其正常工作,我在" ServiceDefinition.csdef"中添加了以下内容:
<WorkerRole name="SomeProject.Foreman" vmsize="Small">
<Contents>
<Content destination="ClientCustomCode">
<SourceDirectory path="ClientCustomCode" />
</Content>
</Contents>
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" />
<Setting name="SomeProjectDocumentDBURI" />
<Setting name="SomeProjectAuthorizationKey" />
<Setting name="LogLevel" />
<Setting name="RequestQueue" />
<Setting name="RequestErrorQueue" />
<Setting name="NumberOfConcurrentRequests" />
<Setting name="NumberOfRequestsToReadFromAzureQueue" />
<Setting name="StorageConnectionString" />
<Setting name="SomeProjectPnrHistory" />
<Setting name="SomeProjectClientRepository" />
<Setting name="SomeProjectMessagesInProcess" />
</ConfigurationSettings>
<LocalResources>
<LocalStorage name="InstallLogs" sizeInMB="5" cleanOnRoleRecycle="false" />
</LocalResources>
<Startup>
<Task commandLine="install.cmd" executionContext="elevated" taskType="simple">
<Environment>
<Variable name="PathToInstallLogs">
<RoleInstanceValue xpath="/RoleEnvironment/CurrentInstance/LocalResources/LocalResource[@name='InstallLogs']/@path" />
</Variable>
</Environment>
</Task>
</Startup>
</WorkerRole>
<WorkerRole name="SomeProject.Engine" vmsize="Small">
<Contents>
<Content destination="ClientCustomCode">
<SourceDirectory path="ClientCustomCode" />
</Content>
</Contents>
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" />
<Setting name="RequestQueue" />
<Setting name="RequestErrorQueue" />
<Setting name="SomeProjectDocumentDBURI" />
<Setting name="SomeProjectAuthorizationKey" />
<Setting name="LogLevel" />
<Setting name="NumberOfConcurrentRequests" />
<Setting name="NumberOfRequestsToReadFromAzureQueue" />
<Setting name="StorageConnectionString" />
<Setting name="SomeProjectPnrHistory" />
<Setting name="SomeProjectClientRepository" />
<Setting name="SomeProjectMessagesInProcess" />
</ConfigurationSettings>
<LocalResources>
<LocalStorage name="InstallLogs" sizeInMB="5" cleanOnRoleRecycle="false" />
</LocalResources>
<Startup>
<Task commandLine="install.cmd" executionContext="elevated" taskType="simple">
<Environment>
<Variable name="PathToInstallLogs">
<RoleInstanceValue xpath="/RoleEnvironment/CurrentInstance/LocalResources/LocalResource[@name='InstallLogs']/@path" />
</Variable>
</Environment>
</Task>
</Startup>
</WorkerRole>
在云项目中,我在构建事件中添加了以下内容:
-- Pre-build
IF NOT EXIST $(TargetDir)ClientCustSomCode mkdir $(TargetDir)ClientCustomCode
-- Post-build
IF NOT EXIST $(TargetDir)ClientCustomCode mkdir $(TargetDir)ClientCustomCode
copy $(ProjectDir)ClientCustomCode\*.dll $(TargetDir)ClientCustomCode
copy $(ProjectDir)ClientCustomCode\*.pdb $(TargetDir)ClientCustomCode
在实际构建复制的dll的项目文件中:
copy $(TargetName).dll $(SolutionDir)SomeProject\SomeProject.Cloud\ClientCustomCode
copy $(TargetName).pdb $(SolutionDir)SomeProject\SomeProject.Cloud\ClientCustomCode
现在,本地构建没有问题。直到最近它还建立在Team Services上,但是出乎意料的是,没有任何真正的原因(没有任何改变),构建突然开始失败,并出现以下错误:
2016-08-23T08:37:40.3013767Z C:\a\1\s\SomeStuff\SomeProject\SomeProject.Cloud\ServiceDefinition.csdef : error CloudServices089: Cannot find the source directory 'C:\a\1\s\SomeStuff\SomeProject\SomeProject.Cloud\ClientCustomCode' in role SomeProject.Foreman. [C:\a\1\s\SomeStuff\SomeProject\SomeProject.Cloud\SomeProject.Cloud.ccproj]
2016-08-23T08:37:40.3013767Z C:\a\1\s\SomeStuff\SomeProject\SomeProject.Cloud\ServiceDefinition.csdef : error CloudServices089: Cannot find the source directory 'C:\a\1\s\SomeStuff\SomeProject\SomeProject.Cloud\ClientCustomCode' in role SomeProject.Engine. [C:\a\1\s\SomeStuff\SomeProject\SomeProject.Cloud\SomeProject.Cloud.ccproj]
构建日志文件: Download 这里有人可能有想法吗?
答案 0 :(得分:0)
错误CloudServices089:在角色SomeProject.Foreman中找不到源目录'C:\ a \ 1 \ s \ SomeStuff \ SomeProject \ SomeProject.Cloud \ ClientCustomCode'。 [C:\一个\ 1 \ S \ SomeStuff \ SomeProject \ SomeProject.Cloud \ SomeProject.Cloud.ccproj]
install.cmd用于为新目录创建目录和副本程序集。从错误消息,我认为install.cmd没有执行。也许install.cmd没有部署到辅助角色。发布应用程序时,请通过启用远程桌面验证:
我们可以在worker角色实例的目录E:\approot
中找到install.cmd。
请尝试在解决方案中找到install.cmd,然后将“复制到输出目录”设置为“复制”以查看是否有效,如下所示: