However, I don't see a way of creating a PublishProfile for this project type. When I click Publish I get a basic publish wizard and the publish settings are stored in the .csproj file not a .pubxml file. So how can I request a specific project to be published?
The PublishProfile
is used for web project not click once. Just as you said, "basic publish wizard and the publish settings are stored in the .csproj file not a .pubxml file", so PublishProfile
should not be a correct option.
If you want to publish a specific project from solution with msbuild, the simple way is to build the entire solution but only publish one project file, like:
msbuild.exe "ProjectName.csproj" /target:publish /p:PublishDir="$(build.artifactstagingdirectory)\
If using one command line to build and publish is your persistence, you can custom a target to publish the project in the project file, which you want to publish. For example:
<PropertyGroup>
<!-- the folder of the project to build -->
<ProjLocation>..\YourProjectFolder</ProjLocation>
<ProjLocationReleaseDir>$(ProjLocation)\bin\Release</ProjLocationReleaseDir>
<ProjPublishLocation>$(ProjLocationReleaseDir)\app.publish</ProjPublishLocation>
<!-- This is the web-folder, which provides the artefacts for click-once. After this
build the project is actually deployed on the server -->
<DeploymentFolder>D:\server\releases\</DeploymentFolder>
</PropertyGroup>
<Target Name="Publish" DependsOnTargets="Clean">
<Message Text="Publish-Build started for build no $(ApplicationRevision)" />
<MSBuild Projects="$(ProjLocation)/YourProject.csproj" Properties="Configuration=Release" Targets="Publish"/>
<ItemGroup>
<SchoolPlannerSetupFiles Include="$(ProjPublishLocation)\*.*"/>
<SchoolPlannerUpdateFiles Include="$(ProjPublishLocation)\Application Files\**\*.*"/>
</ItemGroup>
<Copy
SourceFiles="@(SchoolPlannerSetupFiles)"
DestinationFolder="$(DeploymentFolder)\"
/>
<Copy
SourceFiles="@(SchoolPlannerUpdateFiles)"
DestinationFolder="$(DeploymentFolder)\Application Files\%(RecursiveDir)"
/>
<CallTarget Targets="RestoreLog"/>
</Target>
<Target Name="Clean">
<Message Text="Clean project:" />
<MSBuild Projects="$(ProjLocation)/YourProject.csproj" Properties="Configuration=Release" Targets="Clean"/>
</Target>
With this custom target, you do not need to publish the project, just need build the solution.
Hope this helps.