How to use Pipeline and Web Deploy Web Publishing (MSDEPLOY) to publish a console application?

I would like to use web deployment to publish the Visual Studio Console application to a folder on the target system.

I was lucky, and I was able to create something similar to what I need, but not quite.

I added the following to the .csproj console:

the following projectName.wpp.targets file has been added

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" /> 

and I added the following projectName.wpp.targets file:

 <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> <PropertyGroup> <DeployAsIisApp>false</DeployAsIisApp> <IncludeSetAclProviderOnDestination>false</IncludeSetAclProviderOnDestination> </PropertyGroup> <ItemGroup> <FilesForPackagingFromProject Include="$(IntermediateOutputPath)$(TargetFileName).config"> <DestinationRelativePath>bin\%(RecursiveDir)%(FileName)%(Extension)</DestinationRelativePath> <FromTarget>projectName.wpp.targets</FromTarget> </FilesForPackagingFromProject> </ItemGroup> </Project> 

Then I edit the .SetParameters.xml file as follows:

 <parameters> <setParameter name="IIS Web Application Name" value="c:\company\project" /> </parameters> 

When I then deploy using the generated .cmd file, I get all the files deployed to C: \ company \ project \ bin.

This is not bad, but I would like to do better. In particular, I would like to omit the bin folder and put all the files in the C: \ company \ project folder, and I would like to specify an ACL

Could anyone get around these problems?

+4
source share
1 answer

So, here's how to omit the bin folder.
First of all, I would like to emphasize that all these msdeploy-related materials are for deploying web applications, and the bin folder seems to me to be deeply hardcoded inside. Therefore, if you want to get rid of this, you must do some dirty things. Which I did.

We need to slightly modify the $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets , so it's better to change it, but it is copied.

Steps:

1.Backup $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets (alternatively, you can install the MSBuild.Microsoft.VisualStudio.Web.targets package, redirect the csproj file to the Microsoft.WebApplication.targets file obtained from the package and work with it).
2. In $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplicaton.targets find the xml node that looks like <CopyPipelineFiles PipelineItems="@(FilesForPackagingFromProject)" (there are several of them, take one of the line ~ 2570 )
3. Comment on the node, replace it with the usual one, so in the end it will look like this:

 <!-- <CopyPipelineFiles PipelineItems="@(FilesForPackagingFromProject)" SourceDirectory="$(WebPublishPipelineProjectDirectory)" TargetDirectory="$(WPPAllFilesInSingleFolder)" SkipMetadataExcludeTrueItems="True" UpdateItemSpec="True" DeleteItemsMarkAsExcludeTrue ="True" Condition="'@(FilesForPackagingFromProject)' != ''"> <Output TaskParameter="ResultPipelineItems" ItemName="_FilesForPackagingFromProjectTempory"/> </CopyPipelineFiles>--> <!-- Copying files to package folder in 'custom'(dirty) way --> <CreateItem Include="$(OutputPath)\**\*.*"> <Output TaskParameter="Include" ItemName="YourFilesToCopy" /> </CreateItem> <Copy SourceFiles="@(YourFilesToCopy)" DestinationFiles="@(YourFilesToCopy->'$(WPPAllFilesInSingleFolder)\%(RecursiveDir)%(Filename)%(Extension)')" /> 

Then
4. Your project Name.wpp.targets should not have FilesForPackagingFromProject , so it will look like this:

 <!-- targets --> <PropertyGroup> <DeployAsIisApp>false</DeployAsIisApp> <IncludeSetAclProviderOnDestination>false</IncludeSetAclProviderOnDestination> </PropertyGroup> <ItemGroup> <!-- intentionally left blank --> </ItemGroup> </Project> 

What is it. Worked for me (tm), tested. Let me be honest, I do not like this approach, but that was the only way I got it to work as it should. It is up to you whether you will use it in your project or not.

My opinion is not to use msdeploy here - this is not a task for you.
It is better to write msbuild scripts from scratch or accept the bin folder and fight the framework again when the next setup is required.

+4
source

Source: https://habr.com/ru/post/1490820/


All Articles