drewnoakes on master
Fix links to blog posts A prev… Merge pull request #334 from tm… (compare)
AArnott on master
Replace old, redundant doc with… (compare)
drewnoakes on AArnott-patch-1
drewnoakes on master
Fix code sample for obtaining t… Merge pull request #333 from mi… (compare)
AArnott on AArnott-patch-1
Fix code sample for obtaining t… (compare)
ProjectReference
describes an unresolved project referenceResolvedProjectReference
describes a resolved project reference, it's populated from the ResolveProjectReferencesDesignTime
target (defined in Microsoft.Common.CurrentVersion.targets
)PropertyPageSchema
s: https://github.com/dotnet/project-system/blob/master/src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/DesignTimeTargets/Microsoft.Managed.DesignTime.targets#L232-L239ReferencesFolder
and DependenciesNode
pull data from these rules I thinkProjectReferences
capability, although I'm not sure if it's really necessary (it enables the project references section in the add reference dialog I think)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()
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.
IBuildProject
altogether if it can't handle this and just use the MSBuild API.ConfiguredProject
is probably tied to a ProjectInstance
under the covers, and that's not getting updated when you do a build.ConfiguredProject
instance or something.ConfiguredProject
is updated in general if this doesn't work.
XXXUnconfiguredProject
class that access the ActiveConfiguredProject
and even have the ActiveConfiguredProject
wrapper class.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?
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.
PackageReferences
capability is for projects which support PackageReference
s 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
@jp2masa Oh, wow. I was poking around those issues and thought I hit a dead end because most references lead to this:
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
.
@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.
packages.config
style instead of PackageReference
.packages.config
and adds it to the project, and downloads the package to a solution-level packages
folder.PackageReference
selected in Tools -> Options as the default and I'm even setting the RestoreProjectStyle
property in my project file to PackageReference
.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.PackageReference
is correctly generated.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 .