Currently I have set up a Web Deployment Project which compiles code into the .\Release
folder. After the build I want to copy the files over to another machine (because whichever directory you build to is deleted then recreated).
The ItemGroup for defining which files to copy is set up as follows:
<ItemGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<ReleaseFiles Include=".\Release\**\*" />
<OverrideFiles Include="..\website\App_Code\override\site.com\**\*" />
</ItemGroup>
'website' is code that is used for multiple sites, so there are several web deployment projects set up within the solution.
Then, I have the AfterBuild target to copy the files:
<Target Name="AfterBuild" Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Copy SourceFiles="@(ReleaseFiles)" ContinueOnError="true" SkipUnchangedFiles="true" DestinationFiles="@(ReleaseFiles->'\\server\web\site.com\%(RecursiveDir)%(Filename)%(Extension)')" />
<Copy SourceFiles="@(OverrideFiles)" DestinationFiles="@(OverrideFiles->'\\server\web\site.com\%(RecursiveDir)%(Filename)%(Extension)')" />
</Target>
However, the ReleaseFiles aren't copied, what can be the cause of that? I have had the error .\TempBuildDir\folder\subfolder - The process cannot access the file because it is being used by another process.
where folder\subfolder
can be different each time, but even when that message doesn't appear the files still aren't copied.
Problem is, it has worked before.
aspx. cs file) must first be compiled. This compilation can happen explicitly or automatically. If the compilation happens explicitly then the entire application's source code is compiled into one or more assemblies ( .
In visual studio open the website to be deployed and choose the website copy web site command. Then click the connect button to display an open website dialog box that lets to choose the destination to copy the web site to. Click the arrow buttons to copy the files from the source web site to remote web site.
To specify a publishing location With a project selected in Solution Explorer, on the Project menu, click Properties. Click the Publish tab. In ClickOnce for . NET Core 3.1 and .
The core trouble is that the ItemGroup in your sample is being evaluated at the time the MSBuild file is loaded - and at that time, most likely, those files don't exist yet.....
Therefore your "ReleaseFiles" and "OverrideFiles" collections are empty, and then nothing gets copied.
What you need to do is create your ItemGroups dynamically after the build has happened (and the files referenced here are indeed present):
<CreateItem Include=".\Release\**\*">
<Output TaskParameter="Include" ItemName="ReleaseFiles"/>
</CreateItem>
<CreateItem Include="..\website\App_Code\override\site.com\**\*">
<Output TaskParameter="Include" ItemName="OverrideFiles"/>
</CreateItem>
Now you should be fine, and the copy task should work.
Marc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With