coapp / coapp.powershell

ClrPlus Signing
52 stars 43 forks source link

Allow importing .targets / .props files #37

Open yodantauber opened 10 years ago

yodantauber commented 10 years ago

I would like to be able to add an external .targets or .props file to my package and have it imported into consuming projects. It may or may not already be possible, but if it is I couldn't figure out how.

fearthecowboy commented 10 years ago

It should be, but I'll test that and get back to you...

synarque commented 10 years ago

The ImportGroupChildren route is empty and there is no memberroute for "Import". This leads props { Import {}} to be taken as a node, and ImportGroup {blablabla} makes an empty . The problem is MSBuild throws an exception if you create an Import node without a Project and I don't understand sufficiently ProjectPlus and the ToRoute concept to propose an implementation. I had a quick one with importgroup but I never managed to get multiple imports and other issues ... Is there another way to do so ? Or do you plan on fixing this ?

fearthecowboy commented 10 years ago

Ah, yeah. I'm out of town this week, I'll try to fix this next week when I get back

synarque commented 10 years ago

Great ! Thanks for the quick reply ! This would be a great addition.

yodantauber commented 10 years ago

Is there any news regarding this? I would love to be able to import external .props / .targets files into consuming projects.

yodantauber commented 10 years ago

In ProjectPlus.cs, I implemented ImportGroupChildren like this:

private IEnumerable<ToRoute> ImportGroupChildren {
    get {
        yield return "".MapTo<ProjectImportGroupElement>((parent, view) =>
        {
            return new ListWithAction<string>(s =>
            {
                // when an item is added
                parent.AddImport(s);
            });
        });
    }
}

In PackageScriptTemplate.autopkg, I added this in the files section:

import_targets += {
    #add-each-file : _targets.ImportGroup.MyTargetImports;
    #destination : ${build_root}/imports/${conditionFolder};
};
import_props += {
    #add-each-file : ::nuget.props.[ ${condition} ].ImportGroup.MyPropImports;
    #destination : ${build_root}/imports/${conditionFolder};
};

Then, in any autopkg script, import_props and import_targets can be used like this (in the files section):

[x64] { import_targets: my_x64_file.targets; }
[win32] { import_props: my_win32_file.props; }
dinazil commented 9 years ago

Should this work in 1.23.521.0?

I have the same property sheet for all configurations so I tried

files {   
    import_props: ..\build\bsii.props;
}

This added the property sheet to the package but when I install it on a project the project sheet is not imported. Adding the [Win32] choice doesn't work either.

When I added both

import_props += {
    #add-each-file : ::nuget.props.[ ${condition} ].ImportGroup.MyPropImports;
    #destination : ${build_root}/imports/${conditionFolder};
};

and

import_props: ..\build\bsii.props;

Then something got installed on the project but it wasn't my property sheet but another one that was generated by CoApp "build\native\bsii.foundations.propertysheets.props" and doesn't contain any redirection to my property sheet.

Also, my property sheet contains redirections to other property sheets. Is it possible to include all of them in the package? I managed adding them to the package using

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

But again I had the problem that the project I install the package on, doesn't import any of the property sheets...

(Also asked about it in StackOverflow)