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

Allow to skip all project targets based on a property value #2071

Open
tmat opened this issue Mar 21, 2018 · 3 comments
Open

Allow to skip all project targets based on a property value #2071

tmat opened this issue Mar 21, 2018 · 3 comments
Milestone

Comments

@tmat
Copy link
Member

tmat commented Mar 21, 2018

Enable project to set a property during evaluation phase that suppresses all targets, including Restore, Build, Pack, etc.

Use cases:

  • when building the .NET Core stack from source we need to skip restoring and building projects and/or specific project target framework for multi-targeting projects that depend on non-OSS libraries.
  • when building on non-Windows machine (or machine that doesn't have Visual Studio installed) some projects might need to be skipped since they require Windows or Visual Studio.

Existing workarounds:

@tmat
Copy link
Member Author

tmat commented Mar 21, 2018

@nguerrera @dsplaisted

@livarcocc livarcocc added this to the Unknown milestone Mar 22, 2018
@rainersigwald
Copy link
Member

One option is to filter projects from the solution metaproject: dotnet/msbuild#1730 (comment).

@ericstj
Copy link
Member

ericstj commented Mar 26, 2019

Agreed we need this sort of feature.

The bit of boilerplate I've used is the following. Properties set might differ depending on what you want it to do. Make sure the name of this is .proj or something that isn't a standard project extension like csproj, vbproj, or fsproj since those all trigger conventions in msbuild. If you want it to have a legitimate

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <!-- don't reference the framework -->
    <DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
    <!-- don't copy any build assets -->
    <SkipCopyBuildProduct>true</SkipCopyBuildProduct>    
    <CopyBuildOutputToPublishDirectory>false</CopyBuildOutputToPublishDirectory>
    <!-- don't generate a deps file -->
    <GenerateDependencyFile>false</GenerateDependencyFile>
    <!-- set TargetPath to a bogus value so it doesn't look like we're producing anything -->
    <TargetPath>NOTHING</TargetPath>
  </PropertyGroup>

  <!-- required by common targets, define them but have them do nothing -->
  <Target Name="CreateManifestResourceNames" />
  <Target Name="CoreCompile" />

  <!-- Import design time targets for Roslyn Project System. These are only available if Visual Studio is installed. -->
  <!-- Required for project to load in Visual Studio. -->
  <PropertyGroup>
    <ManagedDesignTimeTargetsPath Condition="'$(ManagedDesignTimeTargetsPath)'==''">$(MSBuildExtensionsPath)\Microsoft\VisualStudio\Managed\Microsoft.Managed.DesignTime.targets</ManagedDesignTimeTargetsPath>
  </PropertyGroup>
  <Import Project="$(ManagedDesignTimeTargetsPath)" Condition="'$(ManagedDesignTimeTargetsPath)' != '' and Exists('$(ManagedDesignTimeTargetsPath)')" />
</Project>

JL03-Yue pushed a commit that referenced this issue Mar 19, 2024
…118.1 (#2071)

[main] Update dependencies from dotnet/arcade
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

4 participants