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

Project System: AvailableItemName support #113

Closed
davkean opened this issue May 13, 2016 · 13 comments
Closed

Project System: AvailableItemName support #113

davkean opened this issue May 13, 2016 · 13 comments
Assignees
Labels
Feature Request Request for a new feature, or new scenario to be handled. Needs-CPS-work Changes are needed in the closed-source Common Project System (CPS) repo. Parity-Legacy-Feature Missing features from the legacy project system. Resolution-Fixed The bug has been fixed, refer to the milestone to see in which release it was fixed. Triage-Approved Reviewed and prioritized

Comments

@davkean
Copy link
Member

davkean commented May 13, 2016

csproj/msvbproj supports <AvailableItemName> to allow adding to the choice of Build Actions. We should enable them to be dynamically added (such as via a NuGet package) and the project should be able to pick them up without a reload.

Update: Make sure we keep C++ in the loop, while the feature will automatically work for them in non-cached mode, their cached mode will need to be updated to handle it.

@davkean davkean added Area-Project System Feature Request Request for a new feature, or new scenario to be handled. Needs-CPS-work Changes are needed in the closed-source Common Project System (CPS) repo. labels May 13, 2016
@srivatsn srivatsn added this to the Unknown milestone May 24, 2016
@sharwell
Copy link
Member

sharwell commented Mar 9, 2017

For some reason my AvailableItemName items aren't appearing even after a project reload. See tunnelvisionlabs/antlr4cs#193. Here's a link to how these are added:

https://github.com/tunnelvisionlabs/antlr4cs/blob/master/runtime/CSharp/Antlr4BuildTasks/Antlr4.net40.targets#L55-L59

@natidea
Copy link
Contributor

natidea commented Mar 22, 2017

@davkean davkean added the Parity-Legacy-Feature Missing features from the legacy project system. label Mar 22, 2017
@davkean davkean modified the milestones: 16.0, Unknown Mar 22, 2017
@davkean davkean changed the title Project System: AvailableItemName should be able to be dynamically added Project System: AvailableItemName support Mar 22, 2017
@davkean
Copy link
Member Author

davkean commented Jun 15, 2017

ShowMissingItemTypes capability controls whether unknown items show up in the tree - but we still need a way to extend the list of Build Actions in the properties window.

@Neutrino-Sunset
Copy link

This functionality is necessary to make it possible to do things like copy files to the output directory, which laughably, are impossible in Visual Studio without resorting to batch files (or a post build event which is a batch file by another name).

E.g. You have a project subdirectory 'Libs' containing binary dependencies, you want that output to your output directory. If you just select build type 'Content' and 'Copy to output directory' it will end up in $(OutDir)/Libs where your binary dependencies will not be resolved.

The 'fix' was to add this to your project file:

   <ItemGroup>
      <AvailableItemName Include="RootContent">
         <Visible>false</Visible>
      </AvailableItemName>
   </ItemGroup>
   <Target Name="AfterBuild">
      <Copy DestinationFolder="$(OutputPath)" SourceFiles="@(RootContent)" SkipUnchangedFiles="true" />
   </Target> 

...which enabled you to mark the files as 'RootContent' whereupon they would get copied to the output directory.

Now even this hack of a workaround is broken with no mention of an alternative. How do I copy files to my output directory now?

@Neutrino-Sunset
Copy link

This is compounded by the fact that build events are now completely broken too as project environment variables are not expanded, so even using a batch file is now impossible either.

dotnet/sdk#677

Honestly the Dotnet Core / VS2017 tooling is an absolute train wreck.

@kzu
Copy link

kzu commented Jun 22, 2017

@Neutrino-Sunset the easiest way to do that is with something like this:

<ItemGroup>
  <Libs Include="Libs\**\*.*" />
  <Content Include="@(Libs)">
    <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    <TargetPath>%(Filename)%(Extension)</TargetPath>
  </Content>
</ItemGroup>

I consider build events a super old legacy thing that was brought forward for backs compat mostly, but using built-in MSBuild constructs everything is extremely easy.

For example, the elements above automatically integrate with clean, incremental build/copy, etc., without you having to do anything.

And also, it works all the way back to the earliest MSBuild versions, nothing to do with .NET Core or VS2017 honestly.

@Neutrino-Sunset
Copy link

That doesn't work either.

Firstly it ouputs the Libs directory to the output directory even though the TargetPath '%(Filename)%(Extension)' should not do this. Secondly it doesn't delete the Libs directory when you clean the project.

This does work, although it's not pretty and it took time to work out that I'd rather have spent doing something useful.

   <ItemGroup>
      <Libs Include="Libs/*.*" />
   </ItemGroup>   

   <Target Name="CopyLibs" AfterTargets="Compile">
      <Copy SourceFiles="@(Libs)" DestinationFolder="$(OutDir)" />
   </Target>

   <Target Name="DeleteLibs" AfterTargets="Clean">
      <Delete Files="$(OutDir)%(Libs.Filename)%(Libs.Extension)" />
   </Target>

Thanks for putting me on a useful track though.

@sharwell
Copy link
Member

sharwell commented Jul 13, 2017

📝 When implementing this feature, the following should be verified:

  1. Items given a type which corresponds to an AvailableItemName should not be also added as None
  2. Items given a type which corresponds to an AvailableItemName should show up in Solution Explorer

@davkean
Copy link
Member Author

davkean commented Jul 13, 2017

  1. Is quite difficult to do - due to the globbing in the SDK. I think we'll want a different approach where we merge item types.

@sharwell
Copy link
Member

@davkean 2 is really the important item. If 1 is a "must" for some particular project, they can just use <EnableDefaultNoneItems>False</EnableDefaultNoneItems>.

@iskiselev
Copy link

Is it possible to see in solution explorer currently items with non-standard type? At least on VS 2017.4, adding to PropertyGroup <ShowMissingItemTypes>true</ShowMissingItemTypes> does not help for it. At the same time I was able to populate custom Build Action in properties selector dropdown using suggestion from (#2160), but as soon as I change type to my custom item disappears from Solution Explorer. It there any workaround currently available?

@davkean
Copy link
Member Author

davkean commented Dec 4, 2018

@iskiselev To turn on the capability you add the following:

<ItemGroup>
    <ProjectCapability Include="ShowMissingItemTypes" />
</ItemGroup>

Note that this is an experimental feature.

@davkean davkean modified the milestones: 16.0, Backlog Dec 12, 2018
@jjmew jjmew added Triage-Approved Reviewed and prioritized and removed Triage-Approved Reviewed and prioritized labels Jan 14, 2019
@davidwengier davidwengier self-assigned this Jan 17, 2019
@davidwengier
Copy link
Contributor

Changes to enable AvailableItemName support in CPS are in progress (Internal PR). An additional PR will be created to finalize support in this repo once that is complete.

@davidwengier davidwengier modified the milestones: Backlog, 16.1 Jan 17, 2019
@davidwengier davidwengier added this to To do in David Wengier via automation Jan 17, 2019
@davidwengier davidwengier moved this from To do to In review in David Wengier Jan 17, 2019
@davidwengier davidwengier moved this from In review to To do in David Wengier Jan 17, 2019
@davidwengier davidwengier moved this from To do to In review in David Wengier Jan 24, 2019
@davkean davkean modified the milestones: 16.1, 16.0, 16.0 Preview 3 Jan 25, 2019
David Wengier automation moved this from In review to Done Jan 25, 2019
@davidwengier davidwengier added the Resolution-Fixed The bug has been fixed, refer to the milestone to see in which release it was fixed. label Jan 25, 2019
eric62369 pushed a commit to eric62369/project-system that referenced this issue Jul 10, 2020
…528.1 (dotnet#113)

- Microsoft.DotNet.Arcade.Sdk - 1.0.0-beta.19278.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Request for a new feature, or new scenario to be handled. Needs-CPS-work Changes are needed in the closed-source Common Project System (CPS) repo. Parity-Legacy-Feature Missing features from the legacy project system. Resolution-Fixed The bug has been fixed, refer to the milestone to see in which release it was fixed. Triage-Approved Reviewed and prioritized
Projects
No open projects
David Wengier
  
Done
Development

No branches or pull requests

9 participants