Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 15 22:45
    tgeng commented #137
  • Oct 03 21:56
    KristianJakubik edited #330
  • Oct 03 21:51
    KristianJakubik commented #330
  • Oct 03 21:50
    KristianJakubik commented #330
  • Oct 03 21:47
    KristianJakubik opened #330
  • Oct 01 21:49
    aodl edited #329
  • Oct 01 21:45
    aodl opened #329
  • Aug 30 11:32
    KristianJakubik edited #328
  • Aug 30 11:21
    KristianJakubik edited #328
  • Aug 30 11:20
    KristianJakubik reopened #328
  • Aug 30 11:20
    KristianJakubik edited #328
  • Aug 30 11:20
    KristianJakubik edited #328
  • Aug 30 11:10
    KristianJakubik closed #328
  • Aug 30 11:10
    KristianJakubik opened #328
  • Aug 26 22:59
    tgeng commented #234
  • Aug 26 22:01
    tgeng commented #234
  • Aug 26 21:16
    tgeng commented #234
  • Aug 05 06:48
    aodl commented #130
  • Aug 05 06:21
    aodl commented #130
  • Aug 05 06:21
    aodl commented #130
jp2masa
@jp2masa
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
Oscar Salazar
@osqui2097
But if I import those common targets in my project configuration file, I can't compile the files added in the project, so what can I do in this case? @jp2masa
jp2masa
@jp2masa
fix your targets, or manually add the targets needed to implement the project reference protocol and design time contracts
Oscar Salazar
@osqui2097
Ok, thank you @jp2masa
Rishabh Verma
@Rishabh-V
Hi Folks! I am facing a strange issue.
I have migrated a solution from .NET Core 1.0 to .NET Core 1.1 (so projects changed from xproj to csproj). When I add a new project from Visual Studio, it works fine. However, if I copy paste an already migrated project, rename it and try to add it to the solution it shows the upgrade dialog, though its already upgraded and is csproj.
The issue I identified is that in sln file it adds a wrong guid for project type, which if I change, it starts working. Just curious to know whats going on so any insights would be very helpful. How does VS determine the guid that it appends in sln file? Thanks.
Kirk Fertitta
@kfertitta

I'd like to export a MEF component whose lifetime matches that of my custom project type -- much like the ProjectNode class in MPFProj. My expectation, based on the docs, is that IProjectDynamicLoadComponent might be an option. However, adding a minimal implementation of this interface results in the UnloadAsync method never getting invoked.

    [Export(ExportContractNames.Scopes.UnconfiguredProject, typeof(IProjectDynamicLoadComponent))]
    [AppliesTo(MyProjectCapabilities.MyProject)]
    internal class MyProjectDynamicLoadComponent : IProjectDynamicLoadComponent
    {
        [Import]
        public UnconfiguredProject UnconfiguredProject { get; set; }

        public async Task LoadAsync()
        {
            await Task.CompletedTask;
        }

        public async Task UnloadAsync()
        {
            await Task.CompletedTask;
        }
    }

If I implement IDisposable, then that is called when the associated project is closed or unloaded. So, I "think" I can get the behavior I want, but it troubles me that I never see UnloadAsync.
Is this the most direct way to have an export that tracks the lifetime automatically of a project?

Oscar Salazar
@osqui2097
@jp2masa I tried to do what you told me, but it doesn't run, which targets I need to fix?
Kirk Fertitta
@kfertitta

I'm trying to distribute a NuGet package as part of my custom project type VSIX, as per these docs:

https://docs.microsoft.com/en-us/nuget/visual-studio-extensibility/visual-studio-templates

The package is properly deployed and the .vstemplate file seems to be working because the packages.config file is automatically created by the new project template. And, the packages.config file does have the correct content in it.

However, when I execute the "Manage NuGet Packages" command, I get the error below:

Note that I have declared the PackageReferences capability, though I don't think it applies here.

image.png
jp2masa
@jp2masa
@osqui2097 the easiest way would be importing the common targets, you can override the values which cause problems...
@kfertitta the PackageReferences capability is for projects which support PackageReferences in the project file, I think it's available for all project systems now (since VS 15.5 or 15.6?), and the wizard shouldn't generate a packages.config, as it's not compatible... also see NuGet/Home#4693
Kirk Fertitta
@kfertitta

@jp2masa Oh, wow. I was poking around those issues and thought I hit a dead end because most references lead to this:

dotnet/project-system#2491

That didn't reference anything on NuGet. So, if PackageReference works, then that's great. And, Andrew Arnott's comment about not using that wizard-based pattern anymore would certainly apply.

It seems all I need to do is delete all the stuff I thought I needed, and then just have the PackageReference.

Kirk Fertitta
@kfertitta

@jp2masa So, if I simply add a PackageReference, then I actually see the same error when I execute "Manage NuGet Packages" on the project.
And, "Manage NuGet Packages for Solution", doesn't list my custom project type in the list of projects.

I've added XAML rules files for PackageReference and ResolvedPackageReference, taken from the .NET project system.
I've also added those to the Imports in my targets file.
Is there another step perhaps I missed?
Thanks in advance.

jp2masa
@jp2masa
there are some capabilities which have to be defined, let me check
Kirk Fertitta
@kfertitta
Thanks @jp2masa . Adding those three capabilities at the top of that link made it all work.
Oscar Salazar
@osqui2097
It worked, thank you @jp2masa
Kirk Fertitta
@kfertitta
@jp2masa I have a NuGet for my custom project system build tools, and I can install it via the Visual Studio Package Manager, but it always uses the packages.config style instead of PackageReference.
It generates the packages.config and adds it to the project, and downloads the package to a solution-level packages folder.
I have PackageReference selected in Tools -> Options as the default and I'm even setting the RestoreProjectStyle property in my project file to PackageReference.
Also, even though it is using packages.config style, installing the package does not inject the automatic Import of my build\<myPackageId>.targets into the project file, even though the package manager says installation succeeded.
When I install the very same NuGet into a C# project, a PackageReference is correctly generated.
When I install the very same NuGet into a C++ project, the packages.config style is used (as that's all C++ supports, I believe), and the Import of my build\<myPackageId>.targets is correctly inserted into the project file .
Also, the package does not show up under my Dependencies node in Solution Explorer.
jp2masa
@jp2masa
you shouldn't use packages.config, but no idea why the package manager is not using package references...
Kirk Fertitta
@kfertitta
Yeah, I don't want to use packages.config.
All I did was take the WindowsScript sample, add the capabilities needed to support NuGet, add the Xaml files for PackageReference and ResolvedPackageReference and that's the behavior your see.
It's identical between my actual project system and the sample with those changes.
jp2masa
@jp2masa
maybe you need to set the package restore style in the props or targets, not sure what's the name of the property
    <RestoreProjectStyle>PackageReference</RestoreProjectStyle>
Kirk Fertitta
@kfertitta
Sorry, should have mentioned that I'd also come across that and already tried it.
Kirk Fertitta
@kfertitta
Still can't figure out why it doesn't work.
Julio César Rocha
@JunielKatarn
Hi. Is there a way to programmatically modify a VC project?
For example, add/remove files and filters, etc.
I'm aware of the Microsoft.VisualStudio.VCProjectEngine namespace, but can't find a way to instantiate the VCProjectEngine interface.
Kirk Fertitta
@kfertitta
@JunielKatarn , You don't instantiate the VCProjectEngine. Rather, you start with an IVsHierarchy:
hierarchy.GetProperty(VSConstants.VSITEMID_ROOT,  __VSHPROPID.VSHPROPID_ExtObject, out var automationProject);
var codeModel = automationProject.CodeModel as VCCodeModel;
var vcProject = automationProject.Object as VCProject;
var fileCodeModel = automationProject.ProjectItems.Item(i).FileCodeModel as VCFileCodeModel;
Kirk Fertitta
@kfertitta

@jp2masa , If you're interested, I see the same behavior with the default Project Type template. I attached a minimal project system. All I did was:

  • Use the Project Type template.
  • Add XAML rules for ProjectReference, ResolvedProjectReference, PackageReference, ResolvedPackageReference.
  • Add the project capabilities referenced in your link above.
  • Imported Microsoft.Common.targets.
  • Added RestoreProjectStyle property.

Try adding any NuGet package to it via the package manager. It succeeds, but adds a packages.config and doesn't add the required imports to the project file.

Julio César Rocha
@JunielKatarn
@kfertitta Thanks!
I’ll give it a try.
Kirk Fertitta
@kfertitta
@JunielKatarn Note that you can also skip the first step if you already have a EnvDTE.Project instance. Just depends on if you're starting from a DTE object or IVsHierarchy.