Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 05 23:34
    drewnoakes opened #331
  • Nov 08 2019 22:25
    twsouthwick commented #298
  • Oct 15 2019 22:45
    tgeng commented #137
  • Oct 03 2019 21:56
    KristianJakubik edited #330
  • Oct 03 2019 21:51
    KristianJakubik commented #330
  • Oct 03 2019 21:50
    KristianJakubik commented #330
  • Oct 03 2019 21:47
    KristianJakubik opened #330
  • Oct 01 2019 21:49
    aodl edited #329
  • Oct 01 2019 21:45
    aodl opened #329
  • Aug 30 2019 11:32
    KristianJakubik edited #328
  • Aug 30 2019 11:21
    KristianJakubik edited #328
  • Aug 30 2019 11:20
    KristianJakubik reopened #328
  • Aug 30 2019 11:20
    KristianJakubik edited #328
  • Aug 30 2019 11:20
    KristianJakubik edited #328
  • Aug 30 2019 11:10
    KristianJakubik closed #328
  • Aug 30 2019 11:10
    KristianJakubik opened #328
  • Aug 26 2019 22:59
    tgeng commented #234
  • Aug 26 2019 22:01
    tgeng commented #234
  • Aug 26 2019 21:16
    tgeng commented #234
  • Aug 05 2019 06:48
    aodl commented #130
Kirk Fertitta
@kfertitta
Ah, ok. Thanks. Will dig into that.
Kirk Fertitta
@kfertitta
So, @jp2masa , is a project tree provider required to populate the child nodes of the "Dependencies" node?
After adding a reference from my custom project system to a C# class library, the project file is properly updated, but nothing appears under "Dependencies".
Not sure if I should expect that to be built in or not.
I see that the Dotnet Project System seems to build it up from scratch completely.
jp2masa
@jp2masa
right, that capability is owned by the .NET project system
I think it subscribes to updates on ProjectReferences and updates the tree
Kirk Fertitta
@kfertitta
Yeah, I'm digging in now.
I'm also looking at your provider in Cosmos.
In your Plugs provider, I'm curious as to how you know the following is the Dependencies node:
        private Task ItemsChangedAsync(IProjectVersionedValue<IProjectCatalogSnapshot> snapshot)
        {
            var nowait = SubmitTreeUpdateAsync(
                (treeSnapshot, configuredProjectExports, cancellationToken) =>
                {
                    var dependenciesNode = treeSnapshot.Value.Tree;

                    if (!cancellationToken.IsCancellationRequested)
                    {
                        dependenciesNode = BuildTree(dependenciesNode, snapshot.Value, cancellationToken);
                    }

                    return Task.FromResult(new TreeUpdateResult(dependenciesNode, lazyFill: false));
                });

            return Task.CompletedTask;
        }
jp2masa
@jp2masa
that's a different node
Kirk Fertitta
@kfertitta
Ah, ok. Thanks. Won't interpret it so literally.
Examples of providers are a bit scarce.
Kirk Fertitta
@kfertitta
So, @jp2masa , what's the real benefit of declaring the "Dependencies" (or, for that matter, the "ReferencesFolder") capabilities, if you have to write a project tree provider anyway to populate the children?
The provider could easily create the "Dependencies" root node anyway.
Or am I missing something?
jp2masa
@jp2masa
you shouldn't have to write the provider
Kirk Fertitta
@kfertitta
But, this is a non-.NET, custom project system.
jp2masa
@jp2masa
do you have both a ProjectReference and ResolvedProjectReference rules?
Kirk Fertitta
@kfertitta
No. Lemme try that.
I have just ProjectReference at present.
jp2masa
@jp2masa
also, do you import Microsoft.Common.CurrentVersion.targets?
Kirk Fertitta
@kfertitta
Hmmn, not doing that in my small sample project.
Will change that too.
Kirk Fertitta
@kfertitta
@jp2masa , Ok, sadly, no joy yet.
I've added XAML rules files for both ProjectReference and ResolvedProjectReference and bring both in via the targets file.
I'm importing Microsoft.Common.targets (also tried .CurrentVersion.targets).
I'm declaring the "ReferencesFolder" and "ProjectReferences" folder. (also tried "Dependencies")
Still see just a References node and no children.
Am I supposed to be subscribing to any item changes at this point (I'm not)?
jp2masa
@jp2masa
this is how it works I think:
Kirk Fertitta
@kfertitta
Thanks @jp2masa . Indeed, I've done exactly those steps.
Must be missing something else simple.
Kirk Fertitta
@kfertitta
If you do those same steps to the WindowsScript sample, it also does not show any child reference nodes.
Kirk Fertitta
@kfertitta

Can anyone comment on the practical difference between accessing the active ConfiguredProject in the following two ways (other than the obvious async different):

UnconfiguredProject.Services.ActiveConfiguredProjectProvider.ActiveProjectConfiguration

versus

UnconfiguredProject.GetSuggestedConfiguredProjectAsync()
Kirk Fertitta
@kfertitta

I'm trying to read the value of a project property that is defined inside a target, like so:

  <Target Name="Test">
    <PropertyGroup>
      <Foo>Kirk</Foo>
    </PropertyGroup>
  </Target>

Thus, the target must run before the Foo property has a value. In our MPFProj-based project system, this worked fine -- just run the target and read the property, as per normal. MPFProj uses the MSBuild API directly.

In an attempt to do the same in our new CPS-based project, we use IBuildProject.BuildAsync and GetEvaluatedPropertyValueAsync. However, the Foo property returns an empty string.

Here is the code:

                        var buildResult = await configuredProject.Services.Build.BuildAsync(new[] { "Test" }, cancellationToken: default, includeUnsavedChanges: true);
                        Debug.Assert(buildResult.OverallResult == BuildResultCode.Success);

                        var f1 = await configuredProject.Services.ProjectPropertiesProvider.GetCommonProperties().GetEvaluatedPropertyValueAsync("Foo");

                        using (var access = await projectLockService.ReadLockAsync())
                        {
                            var project = await access.GetProjectAsync(configuredProject);
                            var projectInstance = BuildManager.DefaultBuildManager.GetProjectInstanceForBuild(project);
                            var success = projectInstance.Build("Test", loggers: null);
                            Debug.Assert(success);

                            var f2 = projectInstance.GetPropertyValue("Foo");
                        }

In the above f1 is an empty string, while f2 correctly prints out the Foo property's value of "Kirk".

Any thoughts on why? It makes me nervous about using IBuildProject as opposed to MSBuild directly.

Thanks in advance.

Kirk Fertitta
@kfertitta
Anybody out there?
jp2masa
@jp2masa
@kfertitta do you still need help with that? the easiest way would be returning the value from a target I think, you can also create a rule and set the data source to the target results if you want
Kirk Fertitta
@kfertitta
@jp2masa Thanks for chiming in. This is still unresolved and feels important/fundamental.
Trouble is, this is a general usage issue as I have LOTS of target-scoped properties like this.
It may be more practical to forego IBuildProject altogether if it can't handle this and just use the MSBuild API.
I can sorta see what's going on -- the ConfiguredProject is probably tied to a ProjectInstance under the covers, and that's not getting updated when you do a build.
Feels like there should be a way to "kick it" and either get an updated ConfiguredProject instance or something.
It's all layered on top of MSBuild, so just feels like I'm missing something.
jp2masa
@jp2masa
I don't think that you're supposed to get properties from targets that often... anyway, did you try using this: https://github.com/Microsoft/VSProjectSystem/blob/master/doc/automation/obtaining_the_MSBuild.Project_from_CPS.md ?
Kirk Fertitta
@kfertitta
@jp2masa , Indeed, I did exactly that. See the code snippet above. I take the project obtained in that fashion and feed it to the MSBuild API in order to get the correct results.
But, there are many actions that could cause properties to change, so I'm unclear on when/how/if the ConfiguredProject is updated in general if this doesn't work.
jp2masa
@jp2masa
that's why you have to acquire the lock I think, so that the project that you get is always up-to-date
Kirk Fertitta
@kfertitta
Yeah, but after leaving the using, reading the properties again still returns an empty string.
I did think about the effect of the lock.
But, build doesn't require a lock, and lots of things can change as a result of a build. Item transforms, etc, etc.
jp2masa
@jp2masa
that's because targets are associated to building, and in VS the project isn't building, you just have a project instance
if you build a target, it wouldn't make sense to affect the instance I think?
Kirk Fertitta
@kfertitta
Well, it has to. And it does in MSBuild directly. The f2 variable prints the correct value -- the value of a property that's only defined in a target.
And MSBuild is underneath the ConfiguredProject.
jp2masa
@jp2masa
right, what I mean is that for example you build the same target multiple times, and that target appends something to a property, you would get the appended part multiple times, that's not what you want
so the project system holds an evaluated project, but only creates instances when building a target I think
Kirk Fertitta
@kfertitta
Hmmn, yeah could be.
That would explain at least part of the behavior.
Seems like my only alternative is to do it with MSBuild, or...
take my properties out of the target.
But, they are defined in terms of task outputs within the target, so the scoping is appropriate from an MSBuild perspective.
jp2masa
@jp2masa
in that case you would return the results from a target and create a rule to consume them
Kirk Fertitta
@kfertitta

Hey, @jp2masa , while you're "here", did you have any thoughts on the question above about which to use between:

UnconfiguredProject.GetSuggestedConfiguredProjectAsync

and

UnconfiguredProject.Services.ActiveConfiguredProjectProvider.ActiveConfiguredProject
jp2masa
@jp2masa
I usually use the first one, not sure about the difference, maybe the second one can be null?
Kirk Fertitta
@kfertitta
Yeah, first one definitely uses more rules and probably can't be null.
It's just that the SDK templates generate imports and such on the XXXUnconfiguredProject class that access the ActiveConfiguredProject and even have the ActiveConfiguredProject wrapper class.
Seem like a lot of things pointing towards those properties, but I, like you, get the impression that it can be null.
Maybe the distinction is more important outside of VS (which I don't care about ... yet) ???
jp2masa
@jp2masa
I honestly never understood why those classes come in the template, I simply removed them and they just make things harder to understand IMO... I also never use ActiveConfiguredProject I think
it's probably null when the project system is being initialized and there's no active configuration yet
maybe for example when exporting a project capabilities provider at the unconfigured project scope, the first time it's queried there's no active configuration I think
Kirk Fertitta
@kfertitta
Good, we're on the same page then.
Thanks much for your help.
Kirk Fertitta
@kfertitta
@jp2masa , is there a CPS API for saving the entire solution, if it's dirty, presumably on IProjectService?
I have a scenario where, for unknown reasons, the usage of IVsSolution.SaveSolutionElement is giving me a bad HRESULT.
Oscar Salazar
@osqui2097
Hi, I need to add my CPS Project System as reference (this project generates a dll based on .Net Framework when it compiles) in a C# project, how can I do that?
jp2masa
@jp2masa
does the project system import the common targets?
Oscar Salazar
@osqui2097
@jp2masa which common targets?
jp2masa
@jp2masa
Microsoft.Common.CurrentVersion.targets