Closed abatishchev closed 4 years ago
This is not a bug in MSBuild. The import of Directory.Build.props
is defined in Microsoft.Common.props
,
TestAgent.csproj
that you shared doesn't import that until the end of the project (through a chain of imports starting with $(MSBuildBinPath)\Microsoft.CSharp.targets
). Therefore, the $(INetRoot)
property isn't defined at the point in where it is referenced (because properties are defined top-to-bottom in the evaluation).
Older csproj templates skipped the .props
import at the top of the file. Newer ones include it, and are generally happier with Directory.Build.props
. I was able to change the behavior of your project with this patch:
diff --git a/src/TestAgent/TestAgent.csproj b/src/TestAgent/TestAgent.csproj
index ce62cda..f42b254 100644
--- a/src/TestAgent/TestAgent.csproj
+++ b/src/TestAgent/TestAgent.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
<PropertyGroup>
<ServiceName>TestAgent</ServiceName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
Issue description
I spoke to the Service Fabric team (@ravipal, @dbreshears, @msnider) and they concluded that it's an issue with rather MSBUild than than with Service Fabric tooling.
The issue is that a variable set in
Directory.Build.props
and used asOutputPath
in a project for Service Fabric service is miscalculated. It's one of:The issue doesn't occur in modern, SDK-based project of the exactly same configuration.
Steps to reproduce
Either include a project sample, attach a zipped project, or provide IDE / CLI steps to create the project and repro the behavior. Example of a project sample:
Project file (the most important piece):
and
Directory.Build.props
content:Directory contents:
Fulll content: TestAgent.zip
Command line
Expected behavior
The project is getting built, packaged, deployed to local cluster.
Actual behavior
or
Environment data
msbuild /version
output:OS info:
If applicable, version of the tool that invokes MSBuild (Visual Studio, dotnet CLI, etc):