我有一个云项目,在目录结构中设置了两个Web角色,如下所示:
C:\myWork\myProject\ Solution.sln \CloudService\CloudService.ccproj \WebRole1\WebRole1.csproj \WebRole2\WebRole2.csproj
我的云服务.csdef是:
<ServiceDefinition name="CloudService" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2015-04.2.6">
<WebRole name="WebRole1" vmsize="Small">
<Sites>
<Site name="WebRole1"
physicalDirectory="..\..\..\WebRole1\publish\_PublishedWebsites\WebRole1">
<Bindings>
<Binding name="http"
endpointName="http"
hostHeader="WebRole1.cloudapp.net" />
</Bindings>
</Site>
<Site name="WebRole2"
physicalDirectory="..\..\..\WebRole2\publish\_PublishedWebsites\WebRole2">
<Bindings>
<Binding name="http"
endpointName="http"
hostHeader="WebRole2.cloudapp.net" />
</Bindings>
</Site>
</Sites>
-snip-
当我在VS2015中打包CloudService项目时,该程序包可以正常构建WebRoles并在包中按预期方式创建。它上传到Azure,两个WebRoles都是活动的,没有错误。
但是,如果我通过命令行使用MSBuild构建:
msbuild /t:corepublish;package /p:visualstudioversion=14.0;targetframeworkversion=4.5;roletargetframework=4.5;config uration=debug
我在CorePublish期间收到以下错误:
CorePublish: CorePublish: PackageWebRole = True Publishing starting... RolePlugins is Importedmodules is Publishing to 'Publishapp.publish\' Creating directory "Publishapp.publish\". TargetServiceDefinition is Publish\ServiceDefinition.csdef TargetServiceConfiguration is Publish\ServiceConfiguration.cscfg Roles is C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Windows Azure Tools\2.6\Microsoft.WindowsAzure.targets(3003,5): warning : CloudServices68 : No TargetFrameworkVersion specified for role WebRole1. Using .NET framework v4.0 for packaging. [c:\mywork\myproject\CloudService\CloudService.ccproj] c:\mywork\myproject\CloudService\Publish\ServiceDefinition.csdef : error CloudServices079: Cannot find the physical directory 'c:\mywork\WebRole1\publish\_PublishedWebsites\WebRole1' for virtual path WebRole1/. [c:\mywork\myproject\CloudService\CloudService.ccproj] Done Building Project "c:\mywork\myproject\CloudService\CloudService.ccproj" (Publish target(s)) -- FAILED. Done Building Project "c:\mywork\myproject\Solution.sln" (Rebuild;Publish target(s)) -- FAILED. Done Building Project "c:\mywork\myproject\cloudservice\cloudservice.ccproj" (corepublish;package target(s)) -- FAILED.
正如您所看到的,MSBuild正在这里寻找WebRole1:c:\mywork\WebRole1
而应该在这里查看:c:\mywork\myproject\WebRole1
。
那么为什么打包云服务在VS2015内部工作,而不是MSBuild?
答案 0 :(得分:0)
我遇到了一个非常类似的问题,在我的情况下,我必须更新MyProject.Azure.ccproj文件,以便始终在PublishPath前加上$(ProjectDir)。最初它不是为TFS构建做的。我现在也是这样做的。我不完全确定我得到的here示例是否具有相关性。
在:
<PropertyGroup Condition=" '$(PublishDestinationPath)'=='' and '$(BuildingInsideVisualStudio)'=='true' ">
<!-- When Visual Studio build -->
<PublishDestinationPath>$(ProjectDir)$(OutDir)</PublishDestinationPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(PublishDestinationPath)'=='' ">
<!-- When TFS build -->
<PublishDestinationPath>$(OutDir)</PublishDestinationPath>
</PropertyGroup>
后:
<PropertyGroup Condition=" '$(PublishDestinationPath)'=='' and '$(BuildingInsideVisualStudio)'=='true' ">
<!-- When Visual Studio build -->
<PublishDestinationPath>$(ProjectDir)$(OutDir)</PublishDestinationPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(PublishDestinationPath)'=='' ">
<!-- When TFS build -->
<PublishDestinationPath>$(ProjectDir)$(OutDir)</PublishDestinationPath>**
</PropertyGroup>