Jude Fisher
Jude Fisher

Reputation: 11284

How can I publish an Azure Cloud Services project with multiple sites on a single service using Visual Studio Team Services?

I have a classic Cloud Services project that has multiple websites on a single service, configured in ServiceDefinition.csdef like so:

<WebRole name="PE.Roles.API" vmsize="Small">
    <Sites>
      <Site name="API" physicalDirectory="..\..\..\PE.Roles.API">
        <Bindings>
          <Binding name="http" endpointName="PE.API" />
        </Bindings>
      </Site>
      <Site name="PE.Services.Authorization" physicalDirectory="..\..\..\PE.Services.Authorization">
        <Bindings>
          <Binding name="http" endpointName="PE.Services.Authorization" />
        </Bindings>
      </Site>
    <!-- Etc -->
    </Sites>
</WebRole>

This compiles and packages correctly in Visual Studio 2015, and deploys without a problem from a precompiled .cspkg file to the Cloud Service.

We have recently moved to Visual Studio Team Services for DevOps, and I'm trying to set this solution up to build and deploy in the cloud, using the provided Azure Cloud Services build template.

The .sln build step completes correctly, but the .ccproj build step fails with the following error:

PE.Azure\bin\ServiceDefinition.csdef (0, 0)
PE.Azure\bin\ServiceDefinition.csdef(0,0): Error CloudServices079: Cannot find the physical directory 'D:\a\1\PE.Roles.API' for virtual path API/.
Process 'msbuild.exe' exited with code '1'.

My build arguments are: /t:Publish /p:TargetProfile=$(targetProfile) /p:DebugType=None /p:SkipInvalidConfigurations=true /p:OutputPath=bin\ /p:PublishDir="$(build.artifactstagingdirectory)\\"

I've found a number of blog posts and SO questions covering similar issues, but nothing that addresses this precisely (and nothing posted in the last few years).

Update

I've created a TFVC repo for the project and implemented the mapping step, as suggested below:

enter image description here

...but I still get the same error: enter image description here

What do I need to do to get this working?

Upvotes: 0

Views: 505

Answers (1)

starian chen-MSFT
starian chen-MSFT

Reputation: 33738

You need to modify source mapping per to the setting of physicalDirectory.

Refer to this sample to modify it:

<Site name="API" physicalDirectory="..\..\..\WebGeneralDemo">
        <Bindings>
          <Binding name="http" endpointName="WebGeneralDemo" />
        </Bindings>
      </Site>

enter image description here

Update:

If these projects are in a git repository, you can keep the structure in repository like this:

-Repo

--AzureCloudServiceDemo

---AzureCloudServiceDemo

---WebRole1

--WebGeneralDemo

If the structure isn't like this, you can copy folders (include files) by using Copy file task

Update

In the case of this specific question, the original structure of the Repo was as follows:

enter image description here

... where the .ccproj file is in the PE.Azure folder, and the site being published is in the PE.Roles.API folder.

The compiler was looking for the site content in the directory one above the $(build.sourcesDirectory) (so D:\a\1\), so the correct Copy File task to fix the error was: enter image description here

A Copy Files task was required for each site, and the tasks had to be positioned after the Build Solution ***.sln step, but before the Build Solution ***.ccproj step.

Upvotes: 2

Related Questions