Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Microsoft.Build.NoTargets does not import Directory.Build.targets #40

Closed
ChristophLindemann opened this issue Jun 21, 2018 · 1 comment

Comments

@ChristophLindemann
Copy link
Contributor

ChristophLindemann commented Jun 21, 2018

Failure:

Microsoft.Build.NoTargets does not support Directory.Build.targets. It does however import Directory.Build.props.

Reason:

This is happens because Microsoft.Common.targets is not imported. Microsoft.Common.props is imported.

Fix / Workaround:

You could include Microsoft.Common.targets or you could include the relevant stuff from the common file:

 
 <PropertyGroup>
    <ImportDirectoryBuildTargets Condition="'$(ImportDirectoryBuildTargets)' == ''">true</ImportDirectoryBuildTargets>
  </PropertyGroup>

  <PropertyGroup Condition="'$(ImportDirectoryBuildTargets)' == 'true' and '$(DirectoryBuildTargetsPath)' == ''">
    <_DirectoryBuildTargetsFile Condition="'$(_DirectoryBuildTargetsFile)' == ''">Directory.Build.targets</_DirectoryBuildTargetsFile>
    <_DirectoryBuildTargetsBasePath Condition="'$(_DirectoryBuildTargetsBasePath)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), '$(_DirectoryBuildTargetsFile)'))</_DirectoryBuildTargetsBasePath>
    <DirectoryBuildTargetsPath Condition="'$(_DirectoryBuildTargetsBasePath)' != '' and '$(_DirectoryBuildTargetsFile)' != ''">$([System.IO.Path]::Combine('$(_DirectoryBuildTargetsBasePath)', '$(_DirectoryBuildTargetsFile)'))</DirectoryBuildTargetsPath>
  </PropertyGroup>
  
  <PropertyGroup Condition="'$(ImportDirectoryBuildTargets)' == 'true' and exists('$(DirectoryBuildTargetsPath)')">
    <MSBuildAllProjects>$(MSBuildAllProjects);$(DirectoryBuildTargetsPath)</MSBuildAllProjects>
  </PropertyGroup>

  <Import Project="$(DirectoryBuildTargetsPath)" Condition="'$(ImportDirectoryBuildTargets)' == 'true' and exists('$(DirectoryBuildTargetsPath)')"/>
@jeffkl
Copy link
Contributor

jeffkl commented Jun 21, 2018

Related: dotnet/sdk#2290

jeffkl pushed a commit that referenced this issue Jun 21, 2018
Microsoft.Common.targets was not imported into NoTargets SDK projects (#42),
resulting in some functionality like Nuget build extensions (#41) and
Directory.Build.targets (#40 ) not working correctly.

Fixes #40
Fixes #41
Fixes #42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants