Scenario: In my project I have a file with a Build Action that I would like to be preserved when I install the package. No file related properties appear to be preserved when installing a package.
Repro:
1. Add a file to the content folder of the project of a package
2. Specify a build action and/or other advanced properties that are written to the project file.
3. Create the package
4. Install the package into an application
Expected: File properties are preserved
Actual: No file properties are preserved
We should provide helpers for this as part of our helper library: http://nuget.codeplex.com/workitem/310
(Other keywords: Content Item, Content Properties)
Comments: Here's the rough design from Anthony Johnston: Overview I was trying to get VS to run CustomTools on install of a particular file type using NuGet But it seem to me that this could be abstracted further to, "when this type of file is installed into a project do something to it" The Flow ProjectManager has a new dependency (with an overload to supply a default) public ProjectManager( IPackageRepository sourceRepository, IPackagePathResolver pathResolver, IProjectSystem project, IPackageRepository localRepository, ProjectFileProcessingBuilder fileProcessingBuilder) { } The builder is used to create a ProjectFileProcessingExecutor specifically for the package, which contains a list of processors to match and run against the files. (see ProjectManager.cs line 248) The ProjectFileProcessingExecutor is passed into IProjectSystem.AddFiles and run after each file is added (see ProjectSystemExtensions.cs line 69) The idea is that the builder would contain a number of Processors for conventions such as "Always set X to Y when a file is of type .ZZZ" and that processors can be additionally to run against files according to the nuspec How far I got The services are all in place and tested Most new stuff is in a folders called ProjectFileProcessing in Core and VisualStudio and some in Core.Authoring What I haven't done is sorted out how a file is matched on add, I had seen some stuff on this using PathResolver, but hadn't got to writing tests and checking this out I suspect when I get IProjectFileProcessingProjectItem.Path I am looking at the wrong one, so that would be what I'd look into next. Also, the processors added by means other than the nuspec, ie the "Conventional Processors" I haven't touched on. But what would be good here is if you could set them up at both the "Global" level in the nuget config and at "Package" level in the nuspec - but you can decide that NuSpec and FileProperties Additional to the nuspec XSD, where you could supply a number of properties to set on install of a file e.g. <package> <metadata> ... </metadata> <files> <file src=""my.txt"" target=""content""> <properties> <property name=""propName1"" value=""propValue"" /> <property name=""propName2"" value=""propValue"" /> </properties> </file> </files> </package> The changes to the XSD are all in place, with ManifestVersionUtility.FilePropertiesVersion (7) setup and tested Important Interfaces & Classes IProjectFileProcessingProject Abstraction of a VsProject for file processing IProjectFileProcessingProjectItem Abstraction of a VsProjectItem for file processing IProjectFileProcessor This interface describes a processor, allows for many processors that do different things to be called by a single service ProjectFileProcessingExecutor Executes the list of IProjectFileProcessors against an item ProjectFileProcessingBuilder Creates an executor (above) and allows for pre-configured processors as well a those added by the nuspec
Repro:
1. Add a file to the content folder of the project of a package
2. Specify a build action and/or other advanced properties that are written to the project file.
3. Create the package
4. Install the package into an application
Expected: File properties are preserved
Actual: No file properties are preserved
We should provide helpers for this as part of our helper library: http://nuget.codeplex.com/workitem/310
(Other keywords: Content Item, Content Properties)
Comments: Here's the rough design from Anthony Johnston: Overview I was trying to get VS to run CustomTools on install of a particular file type using NuGet But it seem to me that this could be abstracted further to, "when this type of file is installed into a project do something to it" The Flow ProjectManager has a new dependency (with an overload to supply a default) public ProjectManager( IPackageRepository sourceRepository, IPackagePathResolver pathResolver, IProjectSystem project, IPackageRepository localRepository, ProjectFileProcessingBuilder fileProcessingBuilder) { } The builder is used to create a ProjectFileProcessingExecutor specifically for the package, which contains a list of processors to match and run against the files. (see ProjectManager.cs line 248) The ProjectFileProcessingExecutor is passed into IProjectSystem.AddFiles and run after each file is added (see ProjectSystemExtensions.cs line 69) The idea is that the builder would contain a number of Processors for conventions such as "Always set X to Y when a file is of type .ZZZ" and that processors can be additionally to run against files according to the nuspec How far I got The services are all in place and tested Most new stuff is in a folders called ProjectFileProcessing in Core and VisualStudio and some in Core.Authoring What I haven't done is sorted out how a file is matched on add, I had seen some stuff on this using PathResolver, but hadn't got to writing tests and checking this out I suspect when I get IProjectFileProcessingProjectItem.Path I am looking at the wrong one, so that would be what I'd look into next. Also, the processors added by means other than the nuspec, ie the "Conventional Processors" I haven't touched on. But what would be good here is if you could set them up at both the "Global" level in the nuget config and at "Package" level in the nuspec - but you can decide that NuSpec and FileProperties Additional to the nuspec XSD, where you could supply a number of properties to set on install of a file e.g. <package> <metadata> ... </metadata> <files> <file src=""my.txt"" target=""content""> <properties> <property name=""propName1"" value=""propValue"" /> <property name=""propName2"" value=""propValue"" /> </properties> </file> </files> </package> The changes to the XSD are all in place, with ManifestVersionUtility.FilePropertiesVersion (7) setup and tested Important Interfaces & Classes IProjectFileProcessingProject Abstraction of a VsProject for file processing IProjectFileProcessingProjectItem Abstraction of a VsProjectItem for file processing IProjectFileProcessor This interface describes a processor, allows for many processors that do different things to be called by a single service ProjectFileProcessingExecutor Executes the list of IProjectFileProcessors against an item ProjectFileProcessingBuilder Creates an executor (above) and allows for pre-configured processors as well a those added by the nuspec