Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Commit 78b90f6

Browse files
kzuadalon
authored andcommitted
Don't show Create NuGet Package command on unloaded projects
1 parent 3eaf82b commit 78b90f6

6 files changed

Lines changed: 57 additions & 30 deletions

File tree

src/VisualStudio/NuGet.Packaging.VisualStudio.15/Templates/Projects/Nuget/Package/Readme.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ Building this project will create a .nupkg containing just this Readme file.
44

55
It's always a good idea to provide a more useful package to your users,
66
alongside a nice descriptive Readme like this one that will open automatically
7-
when the add your package to a project.
7+
when they add your package to a project.
88

99
Happy nugetizing!
Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
{
2-
"dependencies": {
3-
"Clarius.VisualStudio": "1.3.7",
4-
"Clide.Installer": "3.0.105-pre",
5-
"GitInfo": "1.1.32",
6-
"Merq": "1.1.3-alpha",
7-
"Merq.Async": "1.1.3-alpha",
8-
"Microsoft.Build": "15.1.262-preview5",
9-
"Microsoft.VisualStudio.ProjectSystem.SDK": "15.0.594-pre",
10-
"Microsoft.VisualStudio.Shell.14.0": "14.3.25407",
11-
"Microsoft.VisualStudio.Shell.Interop.11.0": "11.0.61030",
12-
"Microsoft.VSSDK.BuildTools": "15.0.26201",
13-
"MSBuilder.DumpItems": "0.2.1",
14-
"MSBuilder.Introspect": "0.1.5",
15-
"MSBuilder.ThisAssembly.Project": "0.3.1",
16-
"MSBuilder.VsixDependency": "0.2.2",
17-
"MSBuilder.VsixInstaller": "0.2.9",
18-
"VSLangProj150": "1.0.0",
19-
"VSSDK.ComponentModelHost.11": "11.0.4"
20-
},
21-
"frameworks": {
22-
"net46": {}
23-
},
24-
"runtimes": {
25-
"win": {}
26-
}
2+
"dependencies": {
3+
"Clarius.VisualStudio": "1.3.7",
4+
"Clide": "3.0.106-pre",
5+
"Clide.Installer": "3.0.106-pre",
6+
"GitInfo": "1.1.32",
7+
"Merq": "1.1.3-alpha",
8+
"Merq.Async": "1.1.3-alpha",
9+
"Microsoft.Build": "15.1.262-preview5",
10+
"Microsoft.VisualStudio.ProjectSystem.SDK": "15.0.594-pre",
11+
"Microsoft.VisualStudio.Shell.14.0": "14.3.25407",
12+
"Microsoft.VisualStudio.Shell.Interop.11.0": "11.0.61030",
13+
"Microsoft.VSSDK.BuildTools": "15.0.26201",
14+
"MSBuilder.DumpItems": "0.2.1",
15+
"MSBuilder.Introspect": "0.1.5",
16+
"MSBuilder.ThisAssembly.Project": "0.3.1",
17+
"MSBuilder.VsixDependency": "0.2.4",
18+
"MSBuilder.VsixInstaller": "0.2.9",
19+
"VSLangProj150": "1.0.0",
20+
"VSSDK.ComponentModelHost.11": "11.0.4"
21+
},
22+
"frameworks": {
23+
"net46": {}
24+
},
25+
"runtimes": {
26+
"win": {}
27+
}
2728
}

src/VisualStudio/NuGet.Packaging.VisualStudio.Shared.targets

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
<PropertyGroup>
1111
<DeployExtension Condition="'$(Configuration)' != 'Debug' Or '$(VisualStudioVersion)' != '$(TargetVSVersion)'" >false</DeployExtension>
12-
12+
<SkipValidatePackageReferences>true</SkipValidatePackageReferences>
13+
1314
<StartAction>Program</StartAction>
1415
<StartProgram Condition="'$(VisualStudioVersion)' &lt; '15.0'">$(MSBuildProgramFiles32)\Microsoft Visual Studio $(VisualStudioVersion)\Common7\IDE\devenv.exe</StartProgram>
1516
<StartProgram Condition="'$(VisualStudioVersion)' &gt;= '15.0'">$(VsInstallRoot)\Common7\IDE\devenv.exe</StartProgram>
@@ -130,4 +131,13 @@
130131
</ItemGroup>
131132
</Target>
132133

134+
<Target Name="CopyLocalAssemblies" AfterTargets="ResolveNuGetPackageAssets">
135+
<ItemGroup>
136+
<Reference Condition=" '%(Filename)' == 'Clide.Interfaces' ">
137+
<CopyLocal>true</CopyLocal>
138+
<Private>true</Private>
139+
</Reference>
140+
</ItemGroup>
141+
</Target>
142+
133143
</Project>

src/VisualStudio/NuGet.Packaging.VisualStudio/Commands/CreateNuGetPackageCommand.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ public CreateNuGetPackageCommand(
3939

4040
protected override void Execute()
4141
{
42+
if (ActiveProject == null)
43+
return;
44+
4245
var project = ActiveProject.As<EnvDTE.Project>();
4346
var vsBuildPropertyStorage = ActiveProject.AsVsHierarchy() as IVsBuildPropertyStorage;
4447
if (vsBuildPropertyStorage != null)
@@ -72,6 +75,6 @@ protected override void CanExecute(OleMenuCommand command) =>
7275

7376
IProjectNode ActiveProject => solutionExplorer.Solution.ActiveProject;
7477

75-
bool CanExecute() => KnownUIContexts.SolutionExistsAndNotBuildingAndNotDebuggingContext.IsActive;
78+
bool CanExecute() => KnownUIContexts.SolutionExistsAndNotBuildingAndNotDebuggingContext.IsActive && ActiveProject != null;
7679
}
7780
}

src/VisualStudio/NuGet.Packaging.VisualStudio/NuGet.Packaging.VisualStudio.targets

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<?xml version="1.0" encoding="utf-8" standalone="no"?>
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
4+
<PropertyGroup>
5+
<SkipValidatePackageReferences>true</SkipValidatePackageReferences>
6+
</PropertyGroup>
37

48
<!-- Because envdte comes from a nuget package, we can't set the EmbedInteropTypes to true in the project, so we do it here -->
59
<Target Name="EmbedInteropTypes" AfterTargets="ResolveNuGetPackageAssets">
@@ -12,5 +16,14 @@
1216
</Reference>
1317
</ItemGroup>
1418
</Target>
15-
19+
20+
<Target Name="CopyLocalAssemblies" AfterTargets="ResolveNuGetPackageAssets">
21+
<ItemGroup>
22+
<Reference Condition=" '%(Filename)' == 'Clide.Interfaces' ">
23+
<CopyLocal>true</CopyLocal>
24+
<Private>true</Private>
25+
</Reference>
26+
</ItemGroup>
27+
</Target>
28+
1629
</Project>

src/VisualStudio/NuGet.Packaging.VisualStudio/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"dependencies": {
3-
"Clide": "3.0.105-pre",
3+
"Clide": "3.0.106-pre",
44
"GitInfo": "1.1.32",
55
"Merq": "1.1.3-alpha",
66
"Microsoft.VisualStudio.Shell.14.0": "14.3.25407",

0 commit comments

Comments
 (0)