Create CoApp package with property sheets

548 views Asked by At

I want to create a CoApp package which will just install my department's custom property sheets (currently they come from a Mercurial subrepository and we want to get rid of as many subrepositories as possible).

The property sheets reside in a a few directories:

- build
  - bsii.props
  - vc12
    - vc12.props
    - debug32.props
    - debug64.props
    - release32.props
    - release64.props
    - details
      - 32.props
      - 64.props
      - common.props
      - debug.props
      - release.props

The main property sheet is build\bsii.props and it has conditional imports which import the rest of the property sheets according to platform and configuration.

For the package to work correctly I need it to contain all the property sheet folder structure and to add the main property sheet bsii.props to the project.

I tried the following autopkg script:

nuget {

    nuspec {
        id = foundations.propertysheets;
        version: 4.0.0.0;
        title: Native Property Sheets;
        ...
    };

    files {
        import_props += { 
            #destination = build\native\imports\;
            ..\build\**\*.props; 
        }
    }
}

This indeed creates a package which contains all the required files but the property sheet is not configured for the project.

When instead I use import_props: ..\build\bsii.props; then the package only contains this single file, but also, it doesn't install it on the project but rather a different .props file generated by CoApp, which doesn't have a reference to my main property sheet:

<Import Project="..\packages\foundations.propertysheets.4.0.0.0\build\native\foundations.propertysheets.props" Condition="Exists('..\packages\foundations.propertysheets.4.0.0.0\build\native\foundations.propertysheets.props')" />

How do I both include all my files in the package and get the package to configure the correct property sheet on the project?

1

There are 1 answers

0
blole On

I don't know about CoApp, but in plain nuget, If you want to add a property sheet to projects and not import MSBuild targets and props files into project (the difference is when during the build it's evaluated), you can do that by putting the property sheet and the following install.ps1 and uninstall.ps1 scripts in the nuget package's tools/ directory.

install.ps1

param($installPath, $toolsPath, $package, $project)

foreach ($config in $project.Properties.Item("Configurations").Object)
{
    $propertySheet = $config.AddPropertySheet("$toolsPath\bsii.props")
}

uninstall.ps1

param($installPath, $toolsPath, $package, $project)

foreach ($config in $project.Properties.Item("Configurations").Object)
{
    $propertySheet = $config.AddPropertySheet("$toolsPath\bsii.props")
    $config.RemovePropertySheet($propertySheet)
}

See https://github.com/blole/visual-studio-builddir/tree/4ccf9bcf2d64d7ce1fd53768a9b5466c033fea46 for a complete nuget package that only installs a single property sheet.