Lack of second level binary links using MSBuild Web Deployment

I am trying to do an automated build / deployment of a web application (.NET 4.0) based on Jenkins. A web application project has several links to projects, which in turn have binary links from third-party DLLs.

Problem:

  • Second-level links (links to project links) are not pulled into the bin folder in the obj\<CONFIGURATION>\Package\PackageTmp\bin , which is used to create deployment packages.
  • When I create a visual studio, second level links are pulled into the regular build output directory.
  • When creating dependencies of the second level using MSBuild, they are not pulled into the standard output directory or into the PackageTmp\bin .

This is confirmed by MS as the Won't Fix problem here .

Related questions here , here and here either do not correspond to my problem, or offer solutions that do not work. I looked through all the answers, not just the accepted ones.

My build team looks like this (using MSBuild 4.0):

MSBuild MySolution.sln / p: Configuration = Integration / p: platform = "Any CPU" / t: Clear, Build / p: DeployOnBuild = true / p: DeployTarget = Package / P: AutoParameterizationWebConfigConnectionStrings = false

I tried to manually edit the Reference elements in the project files, adding <Private>True</Private> , without success.

I am trying to get around this known issue, so my second level dependencies are automatically and correctly pulled into the temp directory of the web publishing.

My current attempt combines the general approach here (setting up the web publishing pipeline by adding the MyProject.wpp.targets file next to the project file website), combined with some MSBuild code to search for the DLL here . So far, this has not yielded any results or broken the project file. I am new to MSBuild custom code and find it rather cryptic.

My question is: I am looking for a more complete example that works in my specific case. I think the goal is to intervene in the web publishing pipeline, which collects files to be copied to the temp directory of the package and adds second-level dependencies to it.

My custom MyWebProj.wpp.targets looks like this:

 <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup> <BRPathFiles Include="$(SolutionDir)..\Common\**\*.dll;$(SolutionDir)**\*.dll" /> <ConfigPathFiles Include="$(SolutionDir)..\Common\**\*.config;$(SolutionDir)**\*.config" /> </ItemGroup> <Target Name="CopySecondLevelDependencies" BeforeTargets="CopyAllFilesToSingleFolderForPackage"> <RemoveDuplicates Inputs="@(BRPathFiles->'%(RootDir)%(Directory)')"> <Output TaskParameter="Filtered" ItemName="BRPaths" /> </RemoveDuplicates> <RemoveDuplicates Inputs="@(ConfigPathFiles->'%(RootDir)%(Directory)')"> <Output TaskParameter="Filtered" ItemName="ConfigPaths" /> </RemoveDuplicates> <CreateItem Include="%(BRPaths.Identity);%(ConfigPaths.Identity);"> <Output ItemName="FileList" TaskParameter="Include"/> </CreateItem> <CreateItem Value="@(BRSearchPath);$(ConfigSearchPath)"> <Output TaskParameter="Value" PropertyName="SecondLevelFiles" /> </CreateItem> </Target> <ItemGroup> <FilesForPackagingFromProject Include="%(SecondLevelFiles->'$(OutDir)%(FileName)%(Extension)')"> <DestinationRelativePath>$(_PackageTempDir)\bin\%(FileName)%(Extension) </DestinationRelativePath> <FromTarget>CopySecondLevelDependencies</FromTarget> <Category>Run</Category> </FilesForPackagingFromProject> </ItemGroup> </Project> 
+4
source share
1 answer

Assuming you have compiled all the libraries needed at runtime in a folder outside of your solution / project, did you try to use post-build events to copy all these libraries to the main project target directory (bin), and then include this directory in your deployment package using the Sayeds method: http://sedodream.com/2010/05/01/WebDeploymentToolMSDeployBuildPackageIncludingExtraFilesOrExcludingSpecificFiles.aspx (also available in this post: How do you include additional files using the VS2010 deployment packages? )?

I have (among others) the following line in my main events after the build:

 xcopy "$(ProjectDir)..\..\Libraries\*.dll" "$(TargetDir)" /Y /S 

In addition to this, I added the following lines to the .csproj file:

 <PropertyGroup> <CopyAllFilesToSingleFolderForPackageDependsOn> PostBuildLibraries; $(CopyAllFilesToSingleFolderForPackageDependsOn); </CopyAllFilesToSingleFolderForPackageDependsOn> </PropertyGroup> <Target Name="PostBuildLibraries"> <ItemGroup> <_PostBuildLibraries Include="$(TargetDir)**\*" /> <FilesForPackagingFromProject Include="%(_PostBuildLibraries.Identity)"> <DestinationRelativePath>$(OutDir)%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath> </FilesForPackagingFromProject> </ItemGroup> </Target> 

Be sure to add these lines after importing "Microsoft.WebApplication.targets". Check out the links above for more details.

This makes all the necessary libraries available after each build (copied to the target project directory) and every time I create a deployment package (copied to obj \ <CONFIGURATION> \ Package \ PackageTmp \ bin).

In addition, since I am building my main project, not my solution, I use the macro $(ProjectDir) instead of $(SolutionDir) .

0
source

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


All Articles