Reputation: 16320
I can build a solution locally and in one project I have post-build events:
xcopy "$(SolutionDir)pluginfolder\bin\Debug\net48\pluginname.*" "$(TargetDir)" /Y
I do this because the target project doesn't have a reference to the plugin projects.
Now I'm trying to move to an Azure pipeline. I created an MSBuild task that builds just the target project and not the complete solution, and I get the following error on running in a self-hosted agent:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(5266,5): Error MSB3073: The command "xcopy "Undefinedpluginfolder\bin\Debug\net48\pluginname.*" "C:\agent_work\5\s\myproj\bin" /Y ended with Code 4.
What is the best approach to solve this issue?
Upvotes: 0
Views: 3446
Reputation: 19461
"Undefinedpluginfolder\bin\Debug\net48\pluginname.*"
The $(SolutionDir) is recognized as Undefined, this is because msbuild has no knowledge about the solution when building a single project.
As workaround, you can insert the following script above the script of PostBuild event. Something like:
<PropertyGroup>
<ProjectFolder>$([System.IO.Directory]::GetParent($(ProjectDir)))</ProjectFolder>
<MySolutionDir>$([System.IO.Directory]::GetParent($(ProjectFolder)))\</MySolutionDir>
It's recommended to add my script and PostBuildEvent in same propertyGroup
<PostBuildEvent>echo $(MySolutionDir)</PostBuildEvent>
</PropertyGroup>
Command line:
xcopy "$(MySolutionDir)pluginfolder\bin\Debug\net48\pluginname.*" "$(TargetDir)" /Y
You can refer to this ticket with similar issue.
Upvotes: 2