Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 17 08:23
    anonymous601 commented #325
  • Jul 01 21:56
    kfertitta opened #337
  • Jul 01 21:41
    kfertitta opened #336
  • Jul 01 21:29
    kfertitta opened #335
  • Jun 14 00:14

    drewnoakes on master

    Fix links to blog posts A prev… Merge pull request #334 from tm… (compare)

  • Jun 14 00:14
    drewnoakes closed #334
  • Jun 12 21:27
    tmeschter opened #334
  • Apr 19 06:00
    manuelxmarquez commented #302
  • Apr 16 19:12
    manuelxmarquez commented #302
  • Apr 16 18:49
    manuelxmarquez commented #302
  • Apr 16 01:51
    manuelxmarquez commented #302
  • Apr 10 21:47

    AArnott on master

    Replace old, redundant doc with… (compare)

  • Mar 23 19:03
    aodl commented #329
  • Mar 18 18:49
    vbisbest commented #329
  • Feb 27 23:45

    drewnoakes on AArnott-patch-1

    (compare)

  • Feb 27 23:45
    drewnoakes closed #333
  • Feb 27 23:45

    drewnoakes on master

    Fix code sample for obtaining t… Merge pull request #333 from mi… (compare)

  • Feb 19 17:00
    AArnott opened #333
  • Feb 19 17:00

    AArnott on AArnott-patch-1

    Fix code sample for obtaining t… (compare)

  • Feb 03 21:02
    amaitland commented #162
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.
Kirk Fertitta
@kfertitta
@jp2masa Are you saying that you've successfully built a custom project system in which PackageReference works?
Still doesn't for me.
jp2masa
@jp2masa
I didn't, but I think it's possible
jp2masa
@jp2masa
are either TargetFramework or TargetFrameworks set?
Kirk Fertitta
@kfertitta
Oh, lemme try that.
Kirk Fertitta
@kfertitta
The operation failed as details for project <myProjectName> could not be loaded.
Kirk Fertitta
@kfertitta
There's a thread on that error seemingly related to non-letter characters in your project path.
Don't think that's the issue, though.
Note that if I just put the PackageReference in my project template, then it will restore and build fine.
That TargetFramework thing looked promising, but this is, of course, not a .NET Framework project - it's my own, so not sure what value to put there anyway.
That particular code you referenced doesn't seem to be using it -- only insisting it's set to something.
But, hard to tell what they're doing in the ctor of that class they're returning.