project-system: $(OutDir) unexpected behavior or $(OutDir) is undefined

I have C# ‘Microsoft.NET.Sdk’ project in D:\Projects\Asm Project is configured for multibuild for net40;net45;net47;netstandard2.0 It have <DocumentationFile>$(OutDir)\Asm.xml</DocumentationFile> parameter

Documentation files are generating in output dirs, but also in D:\Asm.xml

When I use:

	<PropertyGroup Condition="'$(OutDir)'!=''">
		<DocumentationFile>$(OutDir)\Asm.xml</DocumentationFile>
	</PropertyGroup>

No documentation files are generated

When project is located in standard location %userprofile%\source\repos\ project cannot be build (because it cannot write to C:\Asm.xml)

Workaround is use <DocumentationFile>bin\$(Configuration)\$(TargetFramework)\Asm.xml</DocumentationFile> but it makes sides effects when project is build not from Visual Studio

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 3
  • Comments: 19 (11 by maintainers)

Commits related to this issue

Most upvoted comments

It is not a duplicate of 368. Issue 368 is related to Documentation files. This issue is related to unexpected behavior of variables $(OutDir) & $(OutputPath) I already post workaround for DocumentationFile in my issue description.

You should use <GenerateDocumentationFile>true</GenerateDocumentationFile> instead of <DocumentationFile>[path]</DocumentationFile> in SDK-based projects and the project system should be updated to use it: https://github.com/dotnet/project-system/issues/368

@nguerrera Maybe you are right, and there’s nothing to fix, but could you explain why $(OutDir) and $(OutputPath) yield C:\something.xml instead of bin/Debug/Platform/ ?

I had the same problem. In fact $(OutDir) has already have slash at the end. So you should write $(OutDir)Asm.xml instead of $(OutDir)\Asm.xml

@AlexeiScherbakov you have the workaround (almost) yourself, place this and should work for VS and non-VS builds

<PropertyGroup Condition="'$(OutDir)'==''">
  <OutDir>bin\$(Configuration)\$(TargetFramework)\</OutDir>
</PropertyGroup>

$(OutputPath)\Asm.xml , $(IntDir)\Asm.xml ,$(IntermediateOutputPath)\Asm.xml also produces D:\Asm.xml

I also tried $(TargetDir)\Asm.xml

All variables are empty 😦