Skip to content

Commit 7eed4f2

Browse files
author
Scott Bommarito
authored
Merge pull request #3846 from NuGet/dev
[ReleasePrep][2017.04.28]RI of dev into master
2 parents b24f084 + f862709 commit 7eed4f2

File tree

75 files changed

+2210
-447
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+2210
-447
lines changed

.gitignore

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,7 @@ $RECYCLE.BIN/
160160
.DS_Store
161161

162162
# NuGetGallery Specific Ignores
163-
src/NuGetGallery/App_Data/Files/Packages
164-
src/NuGetGallery/App_Data/Files/Downloads
165-
src/NuGetGallery/App_Data/Files/Uploads
166-
src/NuGetGallery/App_Data/Mail
167-
src/NuGetGallery/App_Data/Lucene
163+
src/NuGetGallery/App_Data/**
168164
!src/NuGetGallery/Views/Packages/
169165
!src/NuGetGallery/Branding/Views/Packages/
170166

.vs/config/applicationhost.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@
158158
<virtualDirectory path="/" physicalPath="..\..\src\NuGetGallery" />
159159
</application>
160160
<bindings>
161-
<binding protocol="http" bindingInformation="*:80:nuget.localtest.me" />
162-
<binding protocol="https" bindingInformation="*:443:nuget.localtest.me" />
161+
<binding protocol="http" bindingInformation="*:80:localhost" />
162+
<binding protocol="https" bindingInformation="*:443:localhost" />
163163
</bindings>
164164
</site>
165165
<siteDefaults>

README.md

Lines changed: 30 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -10,79 +10,42 @@ This project has adopted the [Microsoft Open Source Code of Conduct](https://ope
1010

1111
## Build and Run the Gallery in (arbitrary number) easy steps
1212

13-
1. Prerequisites. Install these if you don't already have them:
14-
1. Visual Studio 2015 - Custom install so that you may also install Microsoft SQL Server Data Tools. This will provide the LocalDB that Windows Azure SDK requires.
15-
2. PowerShell 2.0 (comes with Windows 7+)
16-
3. [NuGet](http://docs.nuget.org/docs/start-here/installing-nuget)
17-
4. [Windows Azure SDK](http://www.microsoft.com/windowsazure/sdk/)
13+
1. Prerequisites:
14+
1. Visual Studio 2017 - Install the following `Workloads`:
15+
* ASP.NET and web development
16+
* Azure development
17+
2. PowerShell 4.0
1818
2. Clone it!
1919

20-
```git clone [email protected]:NuGet/NuGetGallery.git```
20+
```PS C:\Code> git clone [email protected]:NuGet/NuGetGallery.git```
2121
3. Build it!
2222

2323
```
24-
cd NuGetGallery
25-
.\build
24+
PS C:\Code> cd NuGetGallery
25+
PS C:\Code\NuGetGallery> .\build
2626
```
27-
4. Set up the website in IIS Express!
28-
1. We highly recommend using IIS Express. Use the [Web Platform Installer](http://microsoft.com/web) to install it if you don't have it already (it comes with recent versions of VS and WebMatrix though). Make sure to at least once run IIS Express as an administrator.
29-
2. In an ADMIN powershell prompt, run the `.\tools\Enable-LocalTestMe.ps1` file. It allows non-admins to host websites at: `http(s)://nuget.localtest.me`, it configures an IIS Express site at that URL and creates a self-signed SSL certificate. For more information on `localtest.me`, check out [readme.localtest.me](http://readme.localtest.me). However, because [Server Name Indication](https://en.wikipedia.org/wiki/Server_Name_Indication) is not supported in the Network Shell on versions of Windows before 8, you must have at least Windows 8 to run this script successfully.
30-
3. If you're having trouble, go to the _Project Properties_ for the Website project, click on the _Web_ tab and change the URL to `localhost:port` where _port_ is some port number above 1024.
31-
32-
5. Create the Database!
33-
34-
There are two ways you can create the databases. From Visual Studio 2015 or from the command line.
35-
36-
1. From Visual Studio 2015
37-
1. Open Visual Studio 2015
38-
2. Open the Package Manager Console window
39-
3. Ensure that the Default Project is set to `NuGetGallery`
40-
4. Open the NuGetGallery.sln solution from the root of this repository. ***Important:*** Make sure the Package Manager Console has been opened once before you open the solution. If the solution was already open, open the package manager console and then close and re-open the solution (from the file menu)
41-
5. Run the following command in the Package Manager Console:
42-
43-
``` powershell
44-
Update-Database -StartUpProjectName NuGetGallery -ConfigurationTypeName MigrationsConfiguration
45-
```
46-
If this fails, you are likely to get more useful output by passing `-Debug` than `-Verbose`.
47-
2. From the command line. ***Important:*** You must have successfully built the Gallery (step 3) for this to succeed.
48-
* Run `Update-Databases.ps1` in the `tools` folder to migrate the databases to the latest version.
49-
* To Update both databases, Nuget Gallery and Support Request, run this command
50-
``` powershell
51-
.\tools\Update-Databases.ps1 -MigrationTargets NugetGallery,NugetGallerySupportRequest
52-
```
53-
* To update only the Nuget Gallery DB, run this
54-
``` powershell
55-
.\tools\Update-Databases.ps1 -MigrationTargets NugetGallery
56-
```
57-
* And to update only the Support Request DB, run this
58-
``` powershell
59-
.\tools\Update-Databases.ps1 -MigrationTargets NugetGallerySupportRequest
60-
```
61-
* Additionally you can provide a `-NugetGallerySitePath` parameter to the `Update-Databases.ps1` script to indicate that you want to perform the migration on a site other than the one that is built with this repository.
62-
63-
6. When working with the gallery, e-mail messages are saved to the file system (under `~/App_Data`).
64-
* To change this to use an SMTP server, edit `src\NuGetGallery\Web.Config` and add a `Gallery.SmtpUri` setting. Its value should be an SMTP connection string, for example `smtp://user:password@smtpservername:25`.
65-
* To turn off e-mail confirmations, edit `src\NuGetGallery\Web.Config` and change the value of `Gallery.ConfirmEmailAddresses` to `false`.
66-
67-
7. Ensure the 'NuGetGallery' project (under the Frontend folder) is set to the Startup Project
68-
69-
70-
That's it! You should now be able to press Ctrl-F5 to run the site!
71-
72-
Be aware that you might detect a change in the __applicationhost.config__:
73-
74-
Unfortunately Visual Studio will replace the relative path with an absolute path. The committed applicationhost.config-file is currently the easiest way to setup the localtest.me-binding for IIS Express.
75-
76-
However, you can force Git to ignore the change with this command:
27+
4. Set up the website!
28+
29+
```PS C:\Code\NuGetGallery> .\tools\Setup-DevEnvironment.ps1```
30+
5. Ensure the `NugetGallery` project is the StartUp Project and press `F5` to run the site! That's it!
31+
32+
When working with the gallery, e-mail messages are saved to the file system (under `~/App_Data`).
33+
You can use an SMTP server instead by editing `src\NuGetGallery\Web.Config` and adding a `Gallery.SmtpUri`
34+
setting. Its value should be an SMTP connection string, such as: `smtp://user:password@smtpservername:25`.
35+
You can also turn off e-email confirmations by changing the value of `Gallery.ConfirmEmailAddresses` to `false`
36+
in the `src\NugetGallery\Web.Config` file.
37+
38+
Visual Studio may modify the `applicationhost.config` file. You can force git to ignore changes to this file
39+
with:
7740
7841
git update-index --assume-unchanged .vs/config/applicationhost.config
7942
8043
You can undo this with this command:
8144
82-
git update-index --no-assume-unchanged .vs/config/applicationhost.config
45+
git update-index --no-assume-unchanged .vs/config/applicationhost.config
8346
84-
This should help to prevent unwanted file commits.
85-
47+
This should help prevent unwanted file commits.
48+
8649
## Contribute
8750
If you find a bug with the gallery, please visit the [Issue tracker](https://github.com/NuGet/NuGetGallery/issues) and
8851
create an issue. If you're feeling generous, please search to see if the issue is already logged before creating a
@@ -122,8 +85,7 @@ This is the Git workflow we're currently using:
12285
12386
### Setting up
12487
125-
1. Clone and checkout the following branches (to make sure local copies are made): '
126-
2. '.
88+
Clone and checkout the `dev` branch.
12789
12890
### When starting a new feature/unit of work.
12991
@@ -136,13 +98,13 @@ This is the Git workflow we're currently using:
13698
git pull dev
13799
138100
2. __Create a topic branch to do your work.__
139-
You must work in topic branches, in order to help us keep our features isolated and easily moved between branches.
101+
You must work in topic branches to help us keep our features isolated and easily moved between branches.
140102
Our policy is to start all topic branches off of the 'dev' branch.
141-
Branch names should use the following format '[user]-[bugnumber]-[shortdescription]'. If there is no bug yet,
103+
Branch names should use the following format '[user]-[bugnumber]'. If there is no bug yet,
142104
create one and assign it to yourself!
143105
144106
git checkout dev
145-
git checkout -b anurse-123-makesuckless
107+
git checkout -b anurse-123
146108
147109
3. __Do your work.__
148110
Now, do your work using the following highly accurate and efficient algorithm :)
@@ -160,7 +122,7 @@ This is the Git workflow we're currently using:
160122
5. if (moreWorkToDo) go to #3.1 else go to #4.
161123
162124
4. __Start a code review.__
163-
Start a code review by pushing your branch up to GitHub (```git push origin anurse-123-makesuckless```) and
125+
Start a code review by pushing your branch up to GitHub (```git push origin anurse-123```) and
164126
creating a Pull Request from your branch to ***dev***. Wait for at least someone on the team to respond with: ":shipit:" (that's called the
165127
"Ship-It Squirrel" and you can put it in your own comments by typing ```:shipit:```).
166128
@@ -171,7 +133,7 @@ This is the Git workflow we're currently using:
171133
172134
git checkout dev
173135
git pull origin dev
174-
git merge anurse-123-makesuckless
136+
git merge anurse-123
175137
... resolve conflicts ...
176138
git push origin dev
177139

build.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ param (
99
[string]$SemanticVersion = '1.0.0-zlocal',
1010
[string]$Branch,
1111
[string]$CommitSHA,
12-
[string]$BuildBranch = '1c479a7381ebbc0fe1fded765de70d513b8bd68e'
12+
[string]$BuildBranch = '37ff6e758c38b3f513af39f881399ce85f4ff20b'
1313
)
1414

15-
# For TeamCity - If any issue occurs, this script fail the build. - By default, TeamCity returns an exit code of 0 for all powershell scripts, even if they fail
15+
# This script should fail the build if any issue occurs.
1616
trap {
1717
Write-Host "BUILD FAILED: $_" -ForegroundColor Red
1818
Write-Host "ERROR DETAILS:" -ForegroundColor Red
@@ -81,7 +81,7 @@ Invoke-BuildStep 'Set version metadata in AssemblyInfo.cs' {
8181

8282
Invoke-BuildStep 'Building solution' {
8383
$SolutionPath = Join-Path $PSScriptRoot "NuGetGallery.sln"
84-
Build-Solution $Configuration $BuildNumber -MSBuildVersion "14" $SolutionPath -SkipRestore:$SkipRestore -MSBuildProperties "/p:MvcBuildViews=true" `
84+
Build-Solution $Configuration $BuildNumber -MSBuildVersion "15" $SolutionPath -SkipRestore:$SkipRestore -MSBuildProperties "/p:MvcBuildViews=true" `
8585
} `
8686
-ev +BuildErrors
8787

src/NuGetGallery.Core/Auditing/AuditedEntities/AuditedPackage.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ public static AuditedPackage CreateFrom(Package package)
5454
Description = package.Description,
5555
ReleaseNotes = package.ReleaseNotes,
5656
DownloadCount = package.DownloadCount,
57-
#pragma warning disable 612
58-
#pragma warning restore 612
5957
HashAlgorithm = package.HashAlgorithm,
6058
Hash = package.Hash,
6159
IconUrl = package.IconUrl,

src/NuGetGallery.Core/Entities/EntitiesContext.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,15 @@ protected override void OnModelCreating(DbModelBuilder modelBuilder)
120120
modelBuilder.Entity<Role>()
121121
.HasKey(u => u.Key);
122122

123+
modelBuilder.Entity<UserSecurityPolicy>()
124+
.HasRequired<User>(p => p.User)
125+
.WithMany(cr => cr.SecurityPolicies)
126+
.HasForeignKey(p => p.UserKey)
127+
.WillCascadeOnDelete(true);
128+
129+
modelBuilder.Entity<UserSecurityPolicy>()
130+
.HasKey(p => p.Key);
131+
123132
modelBuilder.Entity<EmailMessage>()
124133
.HasKey(em => em.Key);
125134

src/NuGetGallery.Core/Entities/User.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public User() : this(null)
1818
public User(string username)
1919
{
2020
Credentials = new List<Credential>();
21+
SecurityPolicies = new List<UserSecurityPolicy>();
2122
Roles = new List<Role>();
2223
Username = username;
2324
}
@@ -52,6 +53,7 @@ public bool Confirmed
5253
public string PasswordResetToken { get; set; }
5354

5455
public DateTime? PasswordResetTokenExpirationDate { get; set; }
56+
5557
public int Key { get; set; }
5658

5759
public DateTime? CreatedUtc { get; set; }
@@ -67,8 +69,11 @@ public string LastSavedEmailAddress
6769
return UnconfirmedEmailAddress ?? EmailAddress;
6870
}
6971
}
72+
7073
public virtual ICollection<Credential> Credentials { get; set; }
7174

75+
public virtual ICollection<UserSecurityPolicy> SecurityPolicies { get; set; }
76+
7277
public void ConfirmEmailAddress()
7378
{
7479
if (string.IsNullOrEmpty(UnconfirmedEmailAddress))
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System.ComponentModel.DataAnnotations;
5+
6+
namespace NuGetGallery
7+
{
8+
/// <summary>
9+
/// User-subscribed security policy.
10+
/// </summary>
11+
public class UserSecurityPolicy : IEntity
12+
{
13+
public UserSecurityPolicy()
14+
{
15+
}
16+
17+
public UserSecurityPolicy(string name)
18+
{
19+
Name = name;
20+
}
21+
22+
/// <summary>
23+
/// Policy key.
24+
/// </summary>
25+
public int Key { get; set; }
26+
27+
/// <summary>
28+
/// User key.
29+
/// </summary>
30+
public int UserKey { get; set; }
31+
32+
/// <summary>
33+
/// User subscribed to this security policy.
34+
/// </summary>
35+
public User User { get; set; }
36+
37+
/// <summary>
38+
/// Type name for the policy handler that provides policy behavior.
39+
/// </summary>
40+
[Required]
41+
public string Name { get; set; }
42+
43+
/// <summary>
44+
/// Support for JSON-serialized properties for specific policies.
45+
/// </summary>
46+
public string Value { get; set; }
47+
}
48+
}

src/NuGetGallery.Core/NuGetGallery.Core.csproj

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,20 @@
8484
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
8585
<HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
8686
</Reference>
87-
<Reference Include="NuGet.Common, Version=4.3.0.2462, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
88-
<HintPath>..\..\packages\NuGet.Common.4.3.0-preview1-2462\lib\net45\NuGet.Common.dll</HintPath>
87+
<Reference Include="NuGet.Common, Version=4.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
88+
<HintPath>..\..\packages\NuGet.Common.4.3.0-preview1-2507\lib\net45\NuGet.Common.dll</HintPath>
8989
</Reference>
90-
<Reference Include="NuGet.Frameworks, Version=4.3.0.2462, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
91-
<HintPath>..\..\packages\NuGet.Frameworks.4.3.0-preview1-2462\lib\net45\NuGet.Frameworks.dll</HintPath>
90+
<Reference Include="NuGet.Frameworks, Version=4.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
91+
<HintPath>..\..\packages\NuGet.Frameworks.4.3.0-preview1-2507\lib\net45\NuGet.Frameworks.dll</HintPath>
9292
</Reference>
93-
<Reference Include="NuGet.Packaging, Version=4.3.0.2462, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
94-
<HintPath>..\..\packages\NuGet.Packaging.4.3.0-preview1-2462\lib\net45\NuGet.Packaging.dll</HintPath>
93+
<Reference Include="NuGet.Packaging, Version=4.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
94+
<HintPath>..\..\packages\NuGet.Packaging.4.3.0-preview1-2507\lib\net45\NuGet.Packaging.dll</HintPath>
9595
</Reference>
96-
<Reference Include="NuGet.Packaging.Core, Version=4.3.0.2462, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
97-
<HintPath>..\..\packages\NuGet.Packaging.Core.4.3.0-preview1-2462\lib\net45\NuGet.Packaging.Core.dll</HintPath>
96+
<Reference Include="NuGet.Packaging.Core, Version=4.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
97+
<HintPath>..\..\packages\NuGet.Packaging.Core.4.3.0-preview1-2507\lib\net45\NuGet.Packaging.Core.dll</HintPath>
9898
</Reference>
99-
<Reference Include="NuGet.Versioning, Version=4.3.0.2462, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
100-
<HintPath>..\..\packages\NuGet.Versioning.4.3.0-preview1-2462\lib\net45\NuGet.Versioning.dll</HintPath>
99+
<Reference Include="NuGet.Versioning, Version=4.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
100+
<HintPath>..\..\packages\NuGet.Versioning.4.3.0-preview1-2507\lib\net45\NuGet.Versioning.dll</HintPath>
101101
</Reference>
102102
<Reference Include="System" />
103103
<Reference Include="System.ComponentModel.DataAnnotations" />
@@ -175,6 +175,7 @@
175175
<Compile Include="Entities\ReadOnlyModeException.cs" />
176176
<Compile Include="Entities\Role.cs" />
177177
<Compile Include="Entities\Scope.cs" />
178+
<Compile Include="Entities\UserSecurityPolicy.cs" />
178179
<Compile Include="Entities\User.cs" />
179180
<Compile Include="Infrastructure\AzureEntityList.cs" />
180181
<Compile Include="Infrastructure\TableErrorLog.cs" />

src/NuGetGallery.Core/app.config

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,24 @@
2020
</dependentAssembly>
2121
<dependentAssembly>
2222
<assemblyIdentity name="NuGet.Common" publicKeyToken="31bf3856ad364e35" culture="neutral" />
23-
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
23+
<bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
2424
</dependentAssembly>
2525
<dependentAssembly>
2626
<assemblyIdentity name="NuGet.Frameworks" publicKeyToken="31bf3856ad364e35" culture="neutral" />
27-
<bindingRedirect oldVersion="0.0.0.0-4.3.0.2462" newVersion="4.3.0.2462" />
27+
<bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
2828
</dependentAssembly>
2929
<dependentAssembly>
3030
<assemblyIdentity name="NuGet.Versioning" publicKeyToken="31bf3856ad364e35" culture="neutral" />
31-
<bindingRedirect oldVersion="0.0.0.0-4.3.0.2462" newVersion="4.3.0.2462" />
31+
<bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
3232
</dependentAssembly>
3333
<dependentAssembly>
3434
<assemblyIdentity name="NuGet.Logging" publicKeyToken="31bf3856ad364e35" culture="neutral" />
3535
<bindingRedirect oldVersion="0.0.0.0-3.5.0.0" newVersion="3.5.0.0" />
3636
</dependentAssembly>
37+
<dependentAssembly>
38+
<assemblyIdentity name="NuGet.Packaging.Core" publicKeyToken="31bf3856ad364e35" culture="neutral" />
39+
<bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
40+
</dependentAssembly>
3741
</assemblyBinding>
3842
</runtime>
3943
</configuration>

0 commit comments

Comments
 (0)