text:
FormatException: Input string was not in a correct format

When working on replicating the TabSet component from the last Blazor community standup I got this exception with VS 2017 15.9 and the Blazor 0.7.0-preview1 build:
System.FormatException: Input string was not in a correct format.
 at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
 at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
 at System.String.Format(IFormatProvider provider, String format, Object[] args)
 at Microsoft.AspNetCore.Razor.Language.DefaultRazorDiagnostic.GetMessage(IFormatProvider formatProvider)
 at Microsoft.VisualStudio.Web.Editors.Razor.RazorCodeGenerator.NotifyOnCodeGenerationComplete()
 at Microsoft.VisualStudio.Web.Editors.Razor.RazorCodeGenerator.<>c__DisplayClass67_0.<OnDocumentStructureChanged>b__0()
 at Microsoft.Web.Editor.Utility.GuardedOperations.InvokeExtensionPoint(Object errorSource, Action action)
 --- End of stack trace from previous location where exception was thrown ---
 at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)

Here's the component file I was working on:

    @foreach (var tab in tabs)
    {

             SelectTab(tab))" class="nav-link @(tab==)

    }

@functions {

}

I hit this issue when binding Dictionary<int, string> as configurable menu. After downloading symbols etc I was able to see something DictionaryBlahBlahImpl<> or DictionaryBlahBlahInternal<>.
Switched to string[]
Now with string[] it works.
Code was port from older ASP.net to ASP.net Core w Razor Pages.
No. I have no details. After searching and debugging for couple of hours I felt stupid for another couple of hours.
Maybe catching the Exception and giving meaningful explanation could save us few hours.
cheers

The fix for this is simple so I'm sending it out. I have no concerns if we decide to punt.

Fixed!

authors: danroth27 moljac rynowak


text:
[Test Failure] WebHostFunctionalTests.RunsInIISExpressInProcess

https://dev.azure.com/dnceng/public/_build/results?buildId=89644
2019-02-07T16:54:43.6421120Z   Failed   Microsoft.AspNetCore.Tests.WebHostFunctionalTests.RunsInIISExpressInProcess
2019-02-07T16:54:43.6462813Z   Error Message:
2019-02-07T16:54:43.6475021Z    System.OperationCanceledException : Failed to connect, retry limit exceeded.
2019-02-07T16:54:43.6484190Z   Stack Trace:
2019-02-07T16:54:43.6487983Z      at Microsoft.AspNetCore.Server.IntegrationTesting.RetryHelper.RetryRequest(Func`1 retryBlock, ILogger logger, CancellationToken cancellationToken, Int32 retryCount) in /_/src/Hosting/Server.IntegrationTesting/src/Common/RetryHelper.cs:line 69
2019-02-07T16:54:43.6491929Z      at Microsoft.AspNetCore.Tests.WebHostFunctionalTests.RunsInIISExpressInProcess() in /_/src/DefaultBuilder/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs:line 171
2019-02-07T16:54:43.6493833Z   --- End of stack trace from previous location where exception was thrown ---
2019-02-07T16:54:43.6496707Z   Standard Output Messages:
2019-02-07T16:54:43.6499639Z    | [0.013s] TestLifetime Information: Starting test RunsInIISExpressInProcess at 2019-02-07T16:54:41
2019-02-07T16:54:43.6501598Z    | [0.142s] Microsoft.AspNetCore.Server.IntegrationTesting.IIS.IISExpressDeployer Information: Deploying [Variation] :: ServerType=IISExpress, Runtime=CoreClr, Arch=x64, BaseUrlHint=, Publish=False
2019-02-07T16:54:43.6504673Z    | [0.144s] Microsoft.AspNetCore.Server.IntegrationTesting.IIS.IISExpressDeployer Information: Executing: dotnet F:\vsagent\12\s\src\DefaultBuilder\testassets\CreateDefaultBuilderApp\bin\Release\netcoreapp3.0\CreateDefaultBuilderApp.dll
2019-02-07T16:54:43.6507050Z    | [0.145s] Microsoft.AspNetCore.Server.IntegrationTesting.IIS.IISExpressDeployer Information: ContentRoot: F:\vsagent\12\s\src\DefaultBuilder\testassets\CreateDefaultBuilderApp
2019-02-07T16:54:43.6510379Z    | [0.157s] Microsoft.AspNetCore.Server.IntegrationTesting.IIS.IISExpressDeployer Information: Attempting to start IIS Express on port: 12292
2019-02-07T16:54:43.6512050Z    | [0.171s] Microsoft.AspNetCore.Server.IntegrationTesting.IIS.IISExpressDeployer Debug: Saving Config to C:\Users\vsagent\AppData\Local\Temp\tmpF63F.tmp
2019-02-07T16:54:43.6516861Z    | [0.186s] Microsoft.AspNetCore.Server.IntegrationTesting.IIS.IISExpressDeployer Information: Executing command : C:\Program Files\IIS Express\iisexpress.exe /site:HttpTestSite /config:C:\Users\vsagent\AppData\Local\Temp\tmpF63F.tmp /trace:error /systray:false
2019-02-07T16:54:43.6520071Z    | [0.188s] Microsoft.AspNetCore.Server.IntegrationTesting.IIS.IISExpressDeployer Information: Removing environment variable ASPNETCORE_ENVIRONMENT
2019-02-07T16:54:43.6522200Z    | [0.188s] Microsoft.AspNetCore.Server.IntegrationTesting.IIS.IISExpressDeployer Information: SET ASPNETCORE_DETAILEDERRORS=true
2019-02-07T16:54:43.6526003Z    | [0.189s] Microsoft.AspNetCore.Server.IntegrationTesting.IIS.IISExpressDeployer Information: SET aspnetcore_environment=Development
2019-02-07T16:54:43.6528621Z    | [0.189s] Microsoft.AspNetCore.Server.IntegrationTesting.IIS.IISExpressDeployer Information: SET envKey=envValue
2019-02-07T16:54:43.6531136Z    | [0.189s] Microsoft.AspNetCore.Server.IntegrationTesting.IIS.IISExpressDeployer Information: SET LAUNCHER_PATH=dotnet
2019-02-07T16:54:43.6533990Z    | [0.189s] Microsoft.AspNetCore.Server.IntegrationTesting.IIS.IISExpressDeployer Information: SET LAUNCHER_ARGS=F:\vsagent\12\s\src\DefaultBuilder\testassets\CreateDefaultBuilderApp\bin\Release\netcoreapp3.0\CreateDefaultBuilderApp.dll
2019-02-07T16:54:43.6536764Z    | [0.189s] Microsoft.AspNetCore.Server.IntegrationTesting.IIS.IISExpressDeployer Information: SET ASPNETCORE_CONTENTROOT=F:\vsagent\12\s\src\DefaultBuilder\testassets\CreateDefaultBuilderApp
2019-02-07T16:54:43.6539455Z    | [0.244s] Microsoft.AspNetCore.Server.IntegrationTesting.IIS.IISExpressDeployer Information: iisexpress Process 9708 started
2019-02-07T16:54:43.6542234Z    | [0.501s] Microsoft.AspNetCore.Server.IntegrationTesting.IIS.IISExpressDeployer Information: iisexpress stdout: Starting IIS Express ...
2019-02-07T16:54:43.6544775Z    | [0.547s] Microsoft.AspNetCore.Server.IntegrationTesting.IIS.IISExpressDeployer Information: iisexpress stdout: Initializing the W3 Server Started CTC = 581367734
2019-02-07T16:54:43.6547295Z    | [0.555s] Microsoft.AspNetCore.Server.IntegrationTesting.IIS.IISExpressDeployer Information: iisexpress stdout: W3 Server initializing WinSock.  CTC = 581367750
2019-02-07T16:54:43.6549662Z    | [0.556s] Microsoft.AspNetCore.Server.IntegrationTesting.IIS.IISExpressDeployer Information: iisexpress stdout: W3 Server WinSock initialized.  CTC = 581367750
2019-02-07T16:54:43.6552096Z    | [0.556s] Microsoft.AspNetCore.Server.IntegrationTesting.IIS.IISExpressDeployer Information: iisexpress stdout: W3 Server ThreadPool initialized (ipm has signalled).  CTC = 581367750
2019-02-07T16:54:43.6554394Z    | [0.861s] Microsoft.AspNetCore.Server.IntegrationTesting.IIS.IISExpressDeployer Information: iisexpress stdout: Start listenerChannel http:0
2019-02-07T16:54:43.6556639Z    | [0.865s] Microsoft.AspNetCore.Server.IntegrationTesting.IIS.IISExpressDeployer Information: iisexpress stdout: Successfully registered URL "http://localhost:12292/" for site "HttpTestSite" application "/"
2019-02-07T16:54:43.6558714Z    | [0.865s] Microsoft.AspNetCore.Server.IntegrationTesting.IIS.IISExpressDeployer Information: iisexpress stdout: Registration completed for site "HttpTestSite"
2019-02-07T16:54:43.6561046Z    | [0.865s] Microsoft.AspNetCore.Server.IntegrationTesting.IIS.IISExpressDeployer Information: iisexpress stdout: AppPool 'IISExpressAppPool' initialized
2019-02-07T16:54:43.6563057Z    | [0.866s] Microsoft.AspNetCore.Server.IntegrationTesting.IIS.IISExpressDeployer Information: iisexpress stdout: InitComplete event signalled
2019-02-07T16:54:43.6565422Z    | [0.868s] Microsoft.AspNetCore.Server.IntegrationTesting.IIS.IISExpressDeployer Information: iisexpress stdout: IIS Express is running.
2019-02-07T16:54:43.6567507Z    | [0.873s] Microsoft.AspNetCore.Server.IntegrationTesting.IIS.IISExpressDeployer Information: Started iisexpress successfully. Process Id : 9708, Port: 12292
2019-02-07T16:54:43.6569592Z    | [0.876s] Microsoft.AspNetCore.Server.IntegrationTesting.IIS.IISExpressDeployer Information: Application ready at URL: http://localhost:12292/
2019-02-07T16:54:43.6571647Z    | [0.887s] Microsoft.AspNetCore.Tests.WebHostFunctionalTests Warning: Retry count 1..
2019-02-07T16:54:43.6573841Z    | [0.891s] System.Net.Http.HttpClient Debug: Sending GET http://localhost:12292/
2019-02-07T16:54:43.6575974Z    | [0.965s] System.Net.Http.HttpClient Debug: Received ServiceUnavailable Service Unavailable http://localhost:12292/
2019-02-07T16:54:43.6577966Z    | [0.970s] Microsoft.AspNetCore.Tests.WebHostFunctionalTests Warning: Retrying a service unavailable error.
2019-02-07T16:54:43.6580352Z    | [0.970s] Microsoft.AspNetCore.Tests.WebHostFunctionalTests Warning: Retry count 2..
2019-02-07T16:54:43.6582415Z    | [0.970s] System.Net.Http.HttpClient Debug: Sending GET http://localhost:12292/
2019-02-07T16:54:43.6585706Z    | [0.983s] System.Net.Http.HttpClient Debug: Received ServiceUnavailable Service Unavailable http://localhost:12292/
2019-02-07T16:54:43.6587635Z    | [0.985s] Microsoft.AspNetCore.Tests.WebHostFunctionalTests Warning: Retrying a service unavailable error.
2019-02-07T16:54:43.6589783Z    | [0.985s] Microsoft.AspNetCore.Tests.WebHostFunctionalTests Warning: Retry count 3..
2019-02-07T16:54:43.6591455Z    | [0.986s] System.Net.Http.HttpClient Debug: Sending GET http://localhost:12292/
2019-02-07T16:54:43.6595462Z    | [0.988s] System.Net.Http.HttpClient Debug: Received ServiceUnavailable Service Unavailable http://localhost:12292/
2019-02-07T16:54:43.6597008Z    | [0.988s] Microsoft.AspNetCore.Tests.WebHostFunctionalTests Warning: Retrying a service unavailable error.
2019-02-07T16:54:43.6599074Z    | [0.988s] Microsoft.AspNetCore.Tests.WebHostFunctionalTests Warning: Retry count 4..
2019-02-07T16:54:43.6601127Z    | [0.988s] System.Net.Http.HttpClient Debug: Sending GET http://localhost:12292/
2019-02-07T16:54:43.6603569Z    | [0.990s] System.Net.Http.HttpClient Debug: Received ServiceUnavailable Service Unavailable http://localhost:12292/
2019-02-07T16:54:43.6605961Z    | [0.990s] Microsoft.AspNetCore.Tests.WebHostFunctionalTests Warning: Retrying a service unavailable error.
2019-02-07T16:54:43.6607905Z    | [0.990s] Microsoft.AspNetCore.Tests.WebHostFunctionalTests Warning: Retry count 5..
2019-02-07T16:54:43.6610348Z    | [0.991s] System.Net.Http.HttpClient Debug: Sending GET http://localhost:12292/
2019-02-07T16:54:43.6612811Z    | [0.992s] System.Net.Http.HttpClient Debug: Received ServiceUnavailable Service Unavailable http://localhost:12292/
2019-02-07T16:54:43.6614586Z    | [0.993s] Microsoft.AspNetCore.Tests.WebHostFunctionalTests Warning: Retrying a service unavailable error.
2019-02-07T16:54:43.6618019Z    | [0.993s] Microsoft.AspNetCore.Tests.WebHostFunctionalTests Information: Failed to connect, retry limit exceeded.
2019-02-07T16:54:43.6619795Z    | [0.995s] Microsoft.AspNetCore.Server.IntegrationTesting.IIS.IISExpressDeployer Information: Attempting to cancel process 9708
2019-02-07T16:54:43.6622316Z    | [1.597s] Microsoft.AspNetCore.Server.IntegrationTesting.IIS.IISExpressDeployer Information: iisexpress Process 9708 shut down
2019-02-07T16:54:43.6624727Z    | [1.598s] Microsoft.AspNetCore.Server.IntegrationTesting.IIS.IISExpressDeployer Information: Host process shutting down.
2019-02-07T16:54:43.6627315Z    | [1.599s] Microsoft.AspNetCore.Server.IntegrationTesting.IIS.IISExpressDeployer Information: Successfully terminated host process with process Id '9708'
2019-02-07T16:54:43.6630233Z    | [1.599s] Microsoft.AspNetCore.Server.IntegrationTesting.IIS.IISExpressDeployer Debug: Deleting applicationHost.config file from C:\Users\vsagent\AppData\Local\Temp\tmpF63F.tmp
2019-02-07T16:54:43.6632124Z    | [1.600s] Microsoft.AspNetCore.Server.IntegrationTesting.IIS.IISExpressDeployer Information: [Time]: Total time taken for this test variation '1.4572448' seconds
2019-02-07T16:54:43.6633595Z    | [1.608s] TestLifetime Information: Finished test RunsInIISExpressInProcess in 1.6012841999999998s

Staaaale.

source: gharchive/issue

authors: anurse jkotalik

repo: aspnet/AspNetCore

license: MIT

license_type: permissive

license_source: github-api


text:
Add missing symbols for our packages

#10495 and #10508

See second attempt of https://dnceng.visualstudio.com/internal/_releaseProgress?_a=release-pipeline-progress&releaseId=8097 for validation of the symbol packages

Closing in favour of #10641 Will deal with #10495 early in Preview 7.

source: gharchive/pull-request


text:
[WIP] Link more assemblies using type granularity

Can only be merged after https://github.com/mono/linker/pull/854 and when we take an updated build of the Mono linker that includes that
This is a preferred implementation for https://github.com/aspnet/AspNetCore/issues/17022. It's very nice and simple (doesn't require creating any new MSBuild tasks!), though relies on a new linker feature.
It reduces the out-of-box transferred size for StandaloneApp from 2.17 MB to 1.98 MB.

** DELETING TO REPLACE WITH A DRAFT PR **


text:
FileSystemXmlRepository depends on Windows environment variables when running on CoreCLR

In FileSystemXmlRepository.cs, Line 106 the code assumes that either LOCALAPPDATA or USERPROFILE exists.  If neither does, an ArugmentException will be thrown when Path.Combine is invoked, with null as an argument (since Environment.GetEnvironmentVarible returns null if the variable is not preset).
One could imagine changing the code to look like this:
            // On core CLR, we need to fall back to environment variables.
            var localAppDataPath = Environment.GetEnvironmentVariable("LOCALAPPDATA");
            var userProfilePath = Environment.GetEnvironmentVariable("USERPROFILE");

            // On non-windows, these environment varibles are normally not present
            if (localAppDataPath == null && userProfilePath == null)
            {
                return null;
            }

            var folderPath = localAppDataPath ?? Path.Combine(userProfilePath, "AppData", "Local");
            DirectoryInfo retVal = GetKeyStorageDirectoryFromBaseAppDataPath(folderPath);
            try
            {
                retVal.Create(); // throws if we don't have access, e.g., user profile not loaded
                return retVal;
            }
            catch
            {
                return null;
            }

But it's not clear to me that's the right thing long term.

Would it make sense to resurrect the Environment.GetFolderPath API on Core CLR and have the SpecialFolders enumeration contain an appropriate local app data-equivalent on non-Windows platforms?
FYI - the code base assumes Core CLR == Windows since it was created before the x-plat Core CLR announcements were public. You'll want to inspect all the ifdefs to be sure you catch all such assumptions.

Would it make sense to resurrect the Environment.GetFolderPath API on Core CLR and have the  SpecialFolders  enumeration contain an appropriate local app data-equivalent on non-Windows platforms?

Perhaps.  As the guy that would probably implement that, it's not clear to me what a sane default is.  On OSX, there's a concept of an Application Support folder, which is what we used for this API on Silverlight, but we had no concept of this on Unix.  If we were to do it, I suspect our best answer would end up just giving something back like ~/.coreclr.  I'm not sure how we'll feel about bringing back APIs where we have to invent answers on other platforms.

FYI - the code base assumes Core CLR == Windows since it was created before the x-plat Core CLR announcements were public. You'll want to inspect all the ifdefs to be sure you catch all such occurrences of this assumption in the code base.

I figured as much.  Thanks for the confirmation!

authors: GrabYourPitchforks ellismg

repo: aspnet/DataProtection


text:
Update getting started on *nix for acquiring libicucore.dylib

In beta8 we require libicu-dev on Linux  / icu4con Darwin
We should update the getting started Docs in beta8 to reflect that.

http://docs.asp.net/en/latest/getting-started/installing-on-linux.html
@danroth27  this looks like a critical update needed

already done on the beta8 branch: http://docs.asp.net/en/1.0.0-beta8/getting-started/installing-on-linux.html
We'll merge this over to master after we ship beta8.

authors: Rick-Anderson danroth27 shirhatti

repo: aspnet/Docs


text:
Just Developer.

When I used Swagger before, the document generated have all the comments in ///  ****/// for all APIs and models.  When I tried this with appnet Core version, the comments are stripped.  Did I miss doing anything here?

Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

ID: f34eea37-51a4-6227-f5ed-6501624ad045
Version Independent ID: 2994cf60-0cb7-afa2-20b8-7e2b1117f964
Content: ASP.NET Core Web API help pages with Swagger / Open API
Content Source: aspnetcore/tutorials/web-api-help-pages-using-swagger.md
Service: unspecified
GitHub Login: @RSuter
Microsoft Alias: scaddie

Hi @Straightly, Have you enabled the XML documentation output in the project properties?
NSwag will definetely pick that up and will show the comments in the Swagger UI.

Thanks for contacting us. We believe that the question you've raised have been answered. If you still feel a need to continue the discussion, feel free to reopen it and add your comments.

authors: Rick-Anderson Straightly zuckerthoben


text:
Duplicate input echo entering commands in httprepl

In the screenshot below I had typed set base http://localhost:5000 but some of the characters were echoed to the console more than once (but not all). This makes it incredibly hard to work with the repl!

I have just installed httprepl as per https://www.hanselman.com/blog/ and am running:
$ dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   2.1.401
 Commit:    91b1c13032

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  18.04
 OS Platform: Linux
 RID:         ubuntu.18.04-x64
 Base Path:   /usr/share/dotnet/sdk/2.1.401/

Host (useful for support):
  Version: 2.1.3
  Commit:  124038c13e

.NET Core SDKs installed:
  2.1.300-rc1-008673 [/usr/share/dotnet/sdk]
  2.1.401 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.0-rc1-final [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.3 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.0-rc1-final [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.3 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.0-rc1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.3 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

Duplicate of: https://github.com/aspnet/DotNetTools/issues/489

authors: glennc stuartleeks

repo: aspnet/DotNetTools


text:
Remove ForeignKey API from convention model builder (Issue #782)

See design meeting notes: https://github.com/aspnet/EntityFramework/wiki/Design-Meeting-Notes:-January-15,-2015

:shipit:

authors: AndriySvyryd ajcvickers

repo: aspnet/EntityFramework


text:
Correctly map SQL Server datetime columns

Issue #5715
SQL Server was mapping "datetime" to DbType.DataTime2 parameters. This breaks SQL Server 2005 and also the always encrypted feature of later versions where the automatic conversions from datetime2 don't work.

:shipit:

authors: ajcvickers divega


text:
Relationship from 'User' to 'Customer' not configured because there are multiple properties on one entity type

Since updating to 2.1.0-preview1, I noticed these messages popping at startup.
These are apparently due to multiple foreign keys on one table referencing the same table.
For example :
Customer -> What user created the customer (references User)
Customer -> What user modified the customer (references User)
There are no errors or exceptions thrown but the message spam considerably slows down startup.
My application with 170+ keys takes a full minute to start, and it worked fine in 2.0.1.
The models and context are straight from Scaffold-DbContext with no alteration.
Steps to reproduce
Here is a repro for the issue.
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;

namespace MultipleRelationshipsBug
{
    class Program
    {
        static void Main(string[] args)
        {
            using (var context = new MyContext())
            {
                context.Database.EnsureCreated();
            }

            Console.Read();
        }
    }

    public partial class MyContext : DbContext
    {
        public virtual DbSet<Customer> Customer { get; set; }
        public virtual DbSet<User> User { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
                optionsBuilder.UseSqlServer(@"Server=.;Database=MultipleRelationshipsBug;Trusted_Connection=True;MultipleActiveResultSets=true")
                                .EnableSensitiveDataLogging()
                                .UseLoggerFactory(new LoggerFactory().AddConsole(LogLevel.Debug));
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Customer>(entity =>
            {
                entity.Property(e => e.Id).HasColumnName("id");

                entity.Property(e => e.CreatedByFk).HasColumnName("createdBy_fk");

                entity.Property(e => e.ModifiedByFk).HasColumnName("modifiedBy_fk");

                entity.HasOne(d => d.CreatedByFkNavigation)
                    .WithMany(p => p.CustomerCreatedByFkNavigation)
                    .HasForeignKey(d => d.CreatedByFk)
                    .OnDelete(DeleteBehavior.ClientSetNull)
                    .HasConstraintName("FK_Customer_UserCreated");

                entity.HasOne(d => d.ModifiedByFkNavigation)
                    .WithMany(p => p.CustomerModifiedByFkNavigation)
                    .HasForeignKey(d => d.ModifiedByFk)
                    .OnDelete(DeleteBehavior.ClientSetNull)
                    .HasConstraintName("FK_Customer_UserModified");
            });

            modelBuilder.Entity<User>(entity =>
            {
                entity.Property(e => e.Id).HasColumnName("id");
            });
        }
    }

    public partial class User
    {
        public User()
        {
            CustomerCreatedByFkNavigation = new HashSet<Customer>();
            CustomerModifiedByFkNavigation = new HashSet<Customer>();
        }

        public int Id { get; set; }

        public ICollection<Customer> CustomerCreatedByFkNavigation { get; set; }
        public ICollection<Customer> CustomerModifiedByFkNavigation { get; set; }
    }

    public partial class Customer
    {
        public int Id { get; set; }
        public int CreatedByFk { get; set; }
        public int ModifiedByFk { get; set; }

        public User CreatedByFkNavigation { get; set; }
        public User ModifiedByFkNavigation { get; set; }
    }
}

My .csproj
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.0-preview1-final" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.1.0-preview1-final" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.0-preview1-final" />
    <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.1.0-preview1-final" />
  </ItemGroup>

  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.1.0-preview1-final" />
  </ItemGroup>

</Project>

Further technical details
EF Core version: 2.1.0-preview1-final
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Windows 7 x64
IDE: Visual Studio 2017 15.6.0

@fschlaef Thanks for reporting this. A couple of questions:

How many lines are logged to build the model?
What is the performance like when LogLevel is changed to Information? How about Warning?

@ajcvickers I investigated this further :

The application takes 3 minutes to start, but VS says the debugging session lasted ~10 seconds, and increments seconds at a fraction of realtime speed. So VS is slowing down a lot.
The Garbage Collector is apparently going haywire for some reason (see screenshot) and the CPU is at 100%
The log created just for startup contains 47 000 lines regarding EF for a total of 17MB
The messages are logged with Information level, so setting LogLevel at Information doesn't change anything, but setting at Warning removes the issue

Hope you can make something out of this !

@fschlaef Thanks for the additional information. We're doing a couple of things in this area:

Moving more messages to debug (won't help when running on Debug, but will help for Info level)
Reducing the number of model building messages

The second of these changes is already in out nightly builds (see https://github.com/aspnet/EntityFrameworkCore). Could you test it and see whether the 47000 lines is reduced? Also, could you post a representative sub-section of maybe a 100 or so of the log messages?

I am also experiencing this issue with 2.1.0-preview2-30365. With information level logging we get about 60 messages emitted on startup (for a DB with almost the same amount of entities). Context initialization takes less than a second, so no performance issue.
However, we are worried about the warnings, as they seem to imply that EF is ignoring part of our mapping definitions, and it's unclear what this affects or if there is anything we can do to solve it.

@ajcvickers I got some testing done with 2.1.0-preview2-30366, there are definitely improvements :

Number of messages down from 47 000+ to 12 015 for the same database
VS is still slowing down, but a lot less and the startup takes 45s down from 3 minutes
A lot less madness regarding GC and CPU, see screenshot
Messages are still logged with Information level, but with further changes we could simply add an override for LogLevel "Microsoft.EntityFrameworkCore.Model": "Information" and that would do it
I tried scaffolding to be sure, but nothing changed in the database
I attached a log, this is the only messages logged, the same message is logged for each table in the DB, 3 times over (down to 12 previously).
I got another message logged 12 times that I have no idea what table or field it is. Maybe completely unrelated :

[Information] The best match for foreign key properties "{'Id' : int}" are incompatible with the principal key "{'Name' : string}".

ef210messages.txt

Notes from triage:

Wording should be changed to make it clearer that these are part of the internal conventions process and do not indicate that anything has been done wrong.
We should consider ways to reduce the number of messages. For example, caching and de-duping.
We should consider whether moving some of these to Trace level would help
We should consider whether these messages will really be helpful, either for app developers or us in submitted logs.

Assigning to @AndriySvyryd to ponder and plan.

These log messages can be disabled by filtering out the Model category https://docs.microsoft.com/en-us/ef/core/miscellaneous/logging or by ignoring specific messages:
.ConfigureWarnings(c => c.Log(CoreEventId.MultipleNavigationProperties))

authors: AndriySvyryd ajcvickers fschlaef mnmr

repo: aspnet/EntityFrameworkCore


text:
Seeding DateTime in EF 2.1 throws exception

Describe what is not working as expected.
I am using new way of seeding data in Entity Framework 2.1:
For example,
modelBuilder.Entity<Blog>().HasData(new Blog {BlogId = 1, CreateDate = DateTime.Now});
However, applying this to the database throws an exception.  I can see that in the generated SQL the value comes as '2018-06-01T13:22:13.248-07:00' which is wrong. And since the field is obviously DateTime, I can't format it into the string the way I would want to.
If you are seeing an exception, include the full exceptions details (message and stack trace).
Exception message:

Failed executing DbCommand (1,154ms) [Parameters=[], CommandType='Text', CommandTimeout='320']
IF EXISTS (SELECT * FROM [sys].[identity_columns] WHERE [name] IN (N'group_id', N'application_id', N'create_date', N'group_admin', N'group_description', N'group_module_delete', N'group_module_edit', N'group_module_insert', N'group_module_read', N'group_name', N'update_date') AND [object_id] = OBJECT_ID(N'[User_Groups]'))
    SET IDENTITY_INSERT [User_Groups] ON;
INSERT INTO [User_Groups] ([group_id], [application_id], [create_date], [group_admin], [group_description], [group_module_delete], [group_module_edit], [group_module_insert], [group_module_read], [group_name], [update_date])
VALUES (1, NULL, '2018-06-01T21:10:37.126-07:00', 'Enabled', 'ADMIN', 'Enabled', 'Enabled', 'Enabled', 'Enabled', 'ADMIN', NULL);
IF EXISTS (SELECT * FROM [sys].[identity_columns] WHERE [name] IN (N'group_id', N'application_id', N'create_date', N'group_admin', N'group_description', N'group_module_delete', N'group_module_edit', N'group_module_insert', N'group_module_read', N'group_name', N'update_date') AND [object_id] = OBJECT_ID(N'[User_Groups]'))
    SET IDENTITY_INSERT [User_Groups] OFF;

Conversion failed when converting date and/or time from character string.

Stack trace:
System.Data.SqlClient.SqlException (0x80131904): Conversion failed when converting date and/or time from character string.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite, String methodName)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary`2 parameterValues)
   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteNonQuery(IRelationalConnection connection, IReadOnlyDictionary`2 parameterValues)
   at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationCommandExecutor.ExecuteNonQuery(IEnumerable`1 migrationCommands, IRelationalConnection connection)
   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
   at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String contextType)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
ClientConnectionId:3cc3208c-d4eb-4495-8de9-b3aebd983442
Error Number:241,State:1,Class:16

Further technical details
EF Core version: (found in project.csproj or packages.config)
2.1.0
Database Provider: (e.g. Microsoft.EntityFrameworkCore.SqlServer)
Microsoft.EntityFrameworkCore.SqlServer
Operating system: Windows 10 x64
IDE: (e.g. Visual Studio 2017 15.4) none (dotnet CLI).  VS Community 15.7.3 is installed but not used here.

Note for triage: I was able to reproduce this when the column is mapped to datetime. Columns mapped to datetime2 work okay. Different format string is used for datetime and datetime2:
private const string DateTimeFormatConst = "{0:yyyy-MM-ddTHH:mm:ss.fffK}";
private const string DateTime2FormatConst = "{0:yyyy-MM-ddTHH:mm:ss.fffffffK}";

Interestingly, today I found that comparing a C# date with a database datetime directly would work:
dbContext.Entities.Where(x => x.Created == DateTime.Now)
Using Contains would not:
dbContext.Entities.Where(x => datesArray.Contains(x.Created))

I just pulled version 2.2.0-preview2-35157 from NuGet and found this issue to still be occurring.
As I said before though, it only seems to happen when using .Contains in the expresssion:
repo.Where(x => x.RollDate == today)
produces:
exec sp_executesql N'SELECT [x].[AllTheColumnsHere] FROM [table] AS [x] WHERE ([x].[RollDate] = @__today)',N'@__rollDate_Date_1 datetime2(7)',@__today='2018-09-13 00:00:00'
whereas
repo.Where(x => datesArray.Contains(x.RollDate))
produces
SELECT [x].[AllTheColumnsHere] FROM [table] AS [x] WHERE [x].[RollDate] IN ('2018-09-13T00:00:00.0000000')
Any chance I'm just doing something wrong and there is something I can fix on my end?

@andresdsep This fix did not make it into the preview2 release. This is why the milestone is still set to 2.0.0, and not 2.0.0-preview2.

Hi @ajcvickers @smitpatel
We found a similar issue with EF 2.1, we are getting Conversion failed when converting date and/or time from character string. when we are trying to execute the following code:
await _context.Database.ExecuteSqlCommandAsync($"INTO SomeTable(SomeDateField) VALUES({DateTime.Now:yyyy-MM-dd}");
We could sove it using the following approach:
await _context.Database.ExecuteSqlCommandAsync($"INTO SomeTable(SomeDateField) VALUES({DateTime.Now.ToString("yyyy-MM-dd")}");
Looks like there is a proble with the interpolations....

@andresdsep - I am not seeing exactly same SQL as you but in preview2 package the SQL generated is something like this,
      SELECT [e].[Id], [e].[TheDate]
      FROM [Blogs] AS [e]
      WHERE [e].[TheDate] IN ('2018-09-18T00:00:00.000-07:00')

-07:00 part is incorrect which is fixed here in 2.2.0 package.
@matipaulo - Please file a new issue with detailed repro steps.

@smitpatel - After a lengthy interlude working on other projects, I'm finally able to verify this issue.
I have run the same code as before with the new stable 2.2.0 package and found the same issue is occurring.
When using Contains I'm seeing [x].[RollDate] IN ('2018-12-05T00:00:00.0000000') outputted. When using a simple == I'm seeing ([x].[RollDate] = @__rollDate_Date_0)  ... @__rollDate_Date_0='2018-12-05 00:00:00'

@andresdsep - Please file a new issue with detailed repro steps.

Created: https://github.com/aspnet/EntityFrameworkCore/issues/14095

authors: ajcvickers andresdsep matipaulo smitpatel virshu


text:
CoreCLR 2.0 - TODO for resources in error handling

From @stephentoub on Thursday, August 17, 2017 7:22:57 AM
From @ayende on August 17, 2017 14:7
When a web socket connection is broken, I'm getting this:

I assume that is something that should be fixed :-)
Copied from original issue: dotnet/coreclr#13425
Copied from original issue: aspnet/WebSockets#198

From @stephentoub on Thursday, August 17, 2017 7:22:58 AM
That's coming from here:
https://github.com/aspnet/WebSockets/blob/4e2ecf8a63b9fc78175d1ef62bf2b1918b8b3986/src/Microsoft.AspNetCore.WebSockets/Internal/fx/SR.cs#L22

From @jkotalik on Tuesday, August 22, 2017 11:47:05 PM
Looks like we need to update our copy of WebSockets, I'll go ahead and fix that.

From @jkotalik on Tuesday, August 22, 2017 11:59:38 PM
@anurse Seems like we need to also be copying https://github.com/dotnet/corefx/blob/master/src/System.Net.WebSockets/src/Resources/Strings.resx for the comments?

From @anurse on Wednesday, August 23, 2017 12:48:32 PM
Yep, sounds right

From @anurse on Wednesday, August 23, 2017 4:31:23 PM
I'd propose this for a patch release. If not 2.0.1, then the next one. The risk is low and the impact is pretty high: Having these exception messages be completely bogus strings is not a good thing and it's easy for a customer to encounter this.
Note: the PR for this also brings in some behavior changes, we would need to fully understand those before considering taking those in the patch as well, but taking the exception message changes should have no behavioral impact and should be very safe for patching
/ping @muratg @Eilon

From @davidfowl on Wednesday, August 23, 2017 10:32:29 PM
Damn I forgot to file this bug in 2.0.0 https://github.com/dotnet/corefx/issues/21509 😞

From @Eilon on Thursday, August 24, 2017 9:46:03 AM
Moving out of patch milestone.

From @jkotalik on Monday, September 18, 2017 11:53:31 AM
@anurse Do we still want to merge this in or figure out a better solution?

From @Tratcher on Monday, September 18, 2017 1:44:28 PM
We need to find an non-manual solution.

From @anurse on Monday, September 18, 2017 3:34:01 PM
We need https://github.com/dotnet/corefx/issues/21537, which is still on the queue for 2.1
Then we can just remove the copying altogether

From @jkotalik on Monday, September 18, 2017 3:52:01 PM
Closed my PR as we will wait for corefx to expose their implementation in 2.1.

From @davidfowl on Wednesday, September 20, 2017 1:48:43 AM
Will that package be netstandard?

From @anurse on Wednesday, September 20, 2017 8:36:39 AM
My understanding is yes. It will support the managed implementation on all platforms with non-managed light-ups

From @jkotalik on Thursday, September 28, 2017 2:49:30 PM
Awaiting response from https://github.com/dotnet/corefx/issues/21537 for next action.

From @anurse on Thursday, September 28, 2017 3:49:13 PM
Well, it sounds like we're going to keep copy-🍝 for now, so I guess we should just update our code with the latest. Note that https://github.com/dotnet/corefx/pull/24288 is pending and we may as well wait until that's in to pull it as well.

From @anurse on Friday, September 29, 2017 9:35:04 AM
The PR I referenced has been merged. @jkotalik , we might as well do another code sync from the latest corefx master using the script. It's relatively harmless even if we end up moving away from code sharing and it makes sure we don't accidentally ship another release with this problem ;)

From @jkotalik on Friday, September 29, 2017 9:58:50 AM
I mean the whole problem before was we weren't pulling the resx file for websockets. We will need to add that to the script.

From @anurse on Friday, September 29, 2017 12:09:41 PM
Yeah, I'm not happy about expanding our code-copying, but if they're not going to release an OOB we're going to have to do it eventually. We don't have to rush in to fixing this, but by 2.1 RTM we have to do one of: fix the script and copy the resx, or drop the source copying and switch to an OOBed package.

From @stephentoub on Friday, September 29, 2017 12:22:43 PM

We don't have to rush in to fixing this

Yeah, I suggest you hold off.  I'm still hopeful they'll be an OOB here.

repo: aspnet/Home


text:
ASP.NET Core 2.1 Web API wont start with Microsoft.AspNetCore.All 2.1.1

Issue moved from https://github.com/dotnet/core/issues/1712. Opened by @poteb
ASP.NET Core 2.1 Web API wont start with Microsoft.AspNetCore.All 2.1.1
I'm debugging my Web API from VS 2017 (15.7.1) and it's working with Microsoft.AspNetCore.All 2.1.0.
But if I update Microsoft.AspNetCore.All to 2.1.1 it wont start up. It doesn't even give me an exception, the console window flashes briefly and then the debugger detaches. Downgrading to 2.1.0 fixes this. No help in Windows event log.
dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 2.1.300
Commit: adab45bf0c
Runtime Environment:
OS Name: Windows
OS Version: 10.0.15063
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.1.300\
Host (useful for support):
Version: 2.1.0
Commit: caa7b7e2ba
.NET Core SDKs installed:
1.1.0 [C:\Program Files\dotnet\sdk]
2.0.0 [C:\Program Files\dotnet\sdk]
2.0.2 [C:\Program Files\dotnet\sdk]
2.1.200 [C:\Program Files\dotnet\sdk]
2.1.300 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 1.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 1.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

I'm seeing a similar thing.
I manually installed the runtime for 2.1.1
Microsoft.NETCore.App 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
but now I'm seeing this:
MPC> It was not possible to find any compatible framework version
MPC> The specified framework 'Microsoft.AspNetCore.All', version '2.1.1' was not found.
MPC>   - Check application dependencies and target a framework version installed at:
MPC>       C:\Program Files\dotnet
MPC>   - Installing .NET Core prerequisites might help resolve this problem:
MPC>       http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
MPC>   - The .NET Core framework and SDK can be installed from:
MPC>       https://aka.ms/dotnet-download
MPC>   - The following versions are installed:
MPC>       2.1.0 at [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]

The runtime seems to be only in the Microsoft.NETCore.App folder but not in Microsoft.AspNetCore.All

A similar error occurs when using the nuget package for Microsoft.ASPNetCore.App instead of .All

Release 2.1.1 is still being deployed, please use 2.1.0 instead.

The newest SDK (2.1.301) released today fixed my issue.

I'm encountering this issue with 2.1.1 and 2.1.2

Closing this because it appears people have gotten this working. If anyone is still having a problem, please log a new issue with details and we will investigate. Thanks!

authors: Eilon Tratcher WieserSoftware leecow neridonk phillijw poteb


text:
string.IsNullOrWhiteSpace accepts invalid chars

string.IsNullOrWhiteSpace calls char.IsWhiteSpaceLatin1 to determine if charaters are whitespace. In addition to space (0x20) it also accepts the following as whitespace
// U+0009 = <control> HORIZONTAL TAB
// U+000a = <control> LINE FEED
// U+000b = <control> VERTICAL TAB
// U+000c = <contorl> FORM FEED
// U+000d = <control> CARRIAGE RETURN
// U+0085 = <control> NEXT LINE
// U+00a0 = NO-BREAK SPACE

They will either not be in the headers (rejected by Kestrel) or would throw an exception if used in a header. However you could currently do
response.ContentType = "\r\t\n\f" + (char)(0xa0) + (char)(0x85);

To happily remove the ContentType header; which seems a little incongruous?
More importantly it doesn't inline very well 😉
/cc @Tratcher @halter73

For "text/plain" it rocks in at twice the cost of ValidateHeaderCharaters.

Should it be string.IsNullOrEmpty?

There was already a bug for IsNullOrWhiteSpace somewhere, but I can't find it...

https://github.com/aspnet/HttpAbstractions/search?utf8=✓&q=IsNullOrWhiteSpace
I see 5 instances and I think they could all be changed to string.IsNullOrEmpty(value?.Trim()) or string.IsNullOrEmpty(value)

string.Trim() calls char.IsWhiteSpaceLatin1 on both sides of the string so would be a regression also you could still clear with a string of control characters 😢

Ah, ValidateHeaderCharacters won't let them through so its just whether the contain space (0x20)

Fixed in #906

authors: Tratcher benaadams jkotalik

repo: aspnet/HttpAbstractions


text:
Aspnetcore Module and .NET Core versions support

Hi, is there a list of the .NET Core versions supported for each version of Aspnetcore Module?
Is it like 1:1?

The AspNetCoreModule (ANCM) is backwards compatible. This means that each version of the Windows Hosting Bundle will contain the same version of ANCM. All versions of dotnet should work with all versions of the AspNetCoreModule, however we recommend using the latest version due to MSRC/security issues that have been resolved in the latest version.

@jkotalik thanks!

authors: ehouarn-perret jkotalik

repo: aspnet/IISIntegration


text:
Publishing default ASP.Net Core Web app template to azure doesn't modify the log location in web.config, resulting in no logs being produced #540

With the project created from templates the log path is set to be .\logs\stdout. If the user turns on logging but does not modify the path or delete the attribute the path will be used as is (publish-iis does not change path as it might have been set by the user). When publishing this project for Azure the path won't be correct and no logs are written.
More details:
See: https://github.com/aspnet/Tooling-Internal/issues/540
Need to decide what we want to do.

@moozzyk  is the change in publish-iis command or the templates?
@Eilon @DamianEdwards do we want to fix this for RC2?
cc @danroth27 @glennc

I don't think it can be done in templates (or only in templates). When the application is being created you don't know whether it's going to be published for Azure or IIS. When publish-iis is invoked we know if we are publishing for Azure or not. This is when we have a chance to react. The question is how we should know whether to react. One option is to not put stdoutPath to the web.config by default (this would requires changes in templates) at all. In this case publish-iis will set the path accordingly. Another way is just to leave the templates alone as today and have publish-iis check the value - if the stdoutPath has the default value it would be overwritten otherwise it would be not touched to not overwrite something the user set. In this case the changes are needed only in publish-iis tool.

The other alternative is to have the templates set the log path to %LOG_PATH% like we do for the app and args. Then it publish-iis could check for this default and replace it for normal or azure publish.

If we can make a very simple fix (aka extremely-low-risk) to the templates ASAP then I'm OK with this for RC2. Otherwise, we should revisit this in RTM.

davidebbo commented 7 minutes ago • edited
Today, when git deploying an app to Azure, you end up with this in web.config:

To enable logging (including streaming), you need to change it to:

But Azure Web App already has an existing mechanism to enable logging, and it would be good to just honor it. It works as follows:
there is a file called settings.json in %home%\site\diagnostics
it contains something like this: {"AzureDriveEnabled":true,"AzureDriveTraceLevel":"Error"}
if AzureDriveEnabled is true, it logs to files in %home%\LogFiles\Applicatio

Repasting my comment as your formatting got corrupted (should delete yours to avoid duplication)
Today, when git deploying an app to Azure, you end up with this in web.config:
<aspNetCore processPath="dotnet" arguments=".\AspNetCoreRC2.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />

To enable logging (including streaming), you need to change it to:
<aspNetCore processPath="dotnet" arguments=".\AspNetCoreRC2.dll" stdoutLogEnabled="true" stdoutLogFile="%home%\LogFiles\dotnetcore" forwardWindowsAuthToken="false" />

But Azure Web App already has an existing mechanism to enable logging, and it would be good to just honor it. It works as follows:

there is a file called settings.json in %home%\site\diagnostics
it contains something like this: {"AzureDriveEnabled":true,"AzureDriveTraceLevel":"Error"}
if AzureDriveEnabled is true, it logs to files in %home%\LogFiles\Application

The setting.json based logging mechanism uses .NET tracing - so it's tracing from the application. Here we are talking about IIS capturing whatever was written to standard output and dumping it to a file. Very useful for troubleshooting issues (e.g. startup) but probably not as much for application logging. Application can configure logging and decide to log elsewhere in which case these entries won't show up in stdOutLog. We will hover need to verify if the setting.json based Azure logging mechanism can be used to write application logs.

We decided to overwrite the outpath always to "\?%home%\LogFiles"  when publishing for Antares since the stdoutLog should be used for diagnostic purposes and the folder always exists.

%home%\LogFiles\Application might be a better choice. By default, when looking at log streams in VS, that's the only folder that gets looked at. So if you don't write there, most people will get confused (VS allows changing this, but it's an advanced setting).

@moozzyk please discuss with @glennc, as he's working on a separate logging provider which would likely conflict with this. His approach will grow better into supporting storage logging and more advanced features.

@davidebbo - as I said before - stdoutLogOutput is not for logging it is just for diagnosing (mostly startup) issues. It's especially useful to troubleshoot issues which happen even before we have a logger at all. Configuring a console logger and using stdoutLogOutput to log to a file is not a substitute for a file logger.
As for the path - we have always used %home%\LogFiles\ - feels a bit late to change this and I don't think it works out of the box. I just checked on one of my website on Azure and there is no Application subfolder in LogFiles:
> ls
D:\home\LogFiles
eventlog.xml
kudu

IIS does not create a folder for logging so you set stdoutLogEnabled and nothing is created and you are hitting this: https://github.com/projectkudu/kudu/issues/2014#issuecomment-220402231

I'm not sure I quite buy this argument. The fact is that by default apps are configured with:
loggerFactory.AddConsole(Configuration.GetSection("Logging"));

Such that anything they log using ILogger will go there, for the lifetime of the console app (and not just the startup sequence).
Point is that if this is enabled and so is @glennc's logger, we will end up writing the same content under D:\home\LogFiles twice. And if someone turns on log streaming at the root (which is D:\home\LogFiles), every log line will be streamed twice.

Why would applications in production log to the Console? How do you even read it when you run in Antares (let's say AspNetCoreModule does not have stdoutLog feature)?
stdoutLog is a IIS/AspNetCoreModule feature and not AspNet's and you only turn it on when you need to diagnose things - it's unstructured and you may and will get additional spew not related to your application at all (e.g. when the application starts we Console.WriteLine some things, when there is a misplaced Console.WriteLine in the app it will get it).
If you use stdoutLog only for diagnostic purposes you will get (especially when application starts) some additional content that logger can't get and you should not run your application with stdoutLog enabled otherwise (this is one of the reasons why it is disabled by default).

As long as users keep that off in Azure Web Apps and primarily use the new logger, I guess we're fine. And this will probably be the guidance, with the exception of diagnosing startup condition. If some does turn it on, then they will get duplicate stream, but hopefully this will be rare.

Agreed.

Fixed in 31a6a12

TL;DR: ANCM console logging :sparkles: just works :sparkles: in spite of its accidental existence and lack of support. However, it shouldn't be used probably because 3rd party logging implementations only require a little more effort to install and configure for a much longer list of logging features.
I used the "anti-pattern" for six months here successfully relying upon the ANCM-generated log with production and test apps. I would like to answer this for posterity and then make a completely different argument why it shouldn't be done:

Why would applications in production log to the Console?

.NET Logging is an abstraction for logging and not an implementation. Devs looking for really simple file-based logging are basically forced at :boy: :gun: to use a 3rd party implementation (e.g., Serilog, NLog, etc.) or to roll their own implementation, which is a huge PITA.
Setup is crazy simple: (1) Add a dep on Microsoft.Extensions.Logging.Console, (2) Configure in WebHostBuilder > .ConfigureLogging > options.AddConsole(LogLevel.Warning); with LogLevel.<level> set based on the environment to whatever level you need to log (Warning for production, Debug for development), (3) Console.WriteLine("...") anywhere in the app to shoot logging messages to the console, thus to the file, and (4) Turn on the module logging stdoutLogEnabled="true" and stdoutLogFile=".\logs\logfilename". (5) Done!
It :sparkles: just works :sparkles:. I used this approach for six months and never had a problem. It's simple, secure, reliable, and efficient. It's all many need from a practical standpoint. If you're a small shop and just need one little log for each app to write a few lines into every so often or trap some data on exceptions, this works very well. No bells-and-whistles. Nothing fancy. It :sparkles: just works :sparkles:.
I don't think the concerns hold-up from a practical point-of-view. (1) It doesn't work outside of ANCM: True! but Console.WriteLine("...") still logs to the Debug output on-screen, (2) It's not ASP.NET: So what? idk ... that's not a real reason not to do it IMO, (3) It's unstructured: So what? idk ... that's kind'a the point in that it's simple messages, (4) You'll get output in the log from Console.WriteLine("..."): That's the whole point ... that is how you log. (5) You'll get extra ANCM messages in your log: So what? That's a minimal inconvienance. Then, if there is an ANCM problem, it will get logged right along with the logging that you're doing in the same file.

This is a happy marriage between the simplicity of setting up console logging with the Logging infrastructure and the completely unrelated ANCM shelling out console to a file.
At this point, I would have suggested there should be another repo in .NET, maybe a part of Logging, maybe not, that would provide a basic logging implementation that works just like what the ANCM module is doing: Shelling out console to a file. For those that just want to Console.WriteLine("...") a few bits to a file here and there (or even go as far as I did and log exceptions across the entire app this way), it would work just like what I describe without having to rely upon the ANCM log, without having to use a 3rd party package, and without having to roll your own.
The real reason not to do this as far as I can see are not any of the reasons provided thus far, because they don't say "it isn't simple," "it isn't safe," and/or "it isn't practical." I think the best reason is the pay-for-play argument ... Logging implementations like Serilog, NLog, elmah.io, and Loggr are not much more difficult to setup and use. Because you get so much more bang-for-the-buck with really nice bells-and-whistles, devs should jump right into one of the 3rd party implementations. I still think MS could have done something for this, and I hope MS will, but until then, I see great logging happening with the 3rd party approaches (once you get past some dodgy documentation IMO).

https://github.com/aspnet/Logging/issues/441

Is there any update on enabling logging to azure blob?

@Sharpeli There is no built-in logging implementation. There are implementations though with Azure sinks. Serilog has DocumentDB and Table Storage sinks. Log4Net has an Azure Blob piece.
https://github.com/serilog/serilog/wiki/Provided-Sinks
http://stemarie.github.io/log4net.Azure/

@GuardRex  Thanks GuardRex, looks like the log4net is incompatible with .net core. Is there any workround to make the built-in “ILoggerFactory” or "Diagnostics.Trace" can log to azure blob for asp.net core app ?

@purekrome says on Slack to check out NLog. He says they use it quite a lot with great success, and it has an Azure Blob Storage sink.

https://github.com/nlog/nlog/wiki/Targets
http://stackoverflow.com/questions/23518078/store-nlog-generated-logs-to-azure-blob-storage-in-seperate-columns
http://stackoverflow.com/questions/35058029/how-to-integrate-nlog-to-write-log-to-azure-streaming-log
https://aspnetcore.slack.com/messages/general/details/

Disclaimer:

I've never logged to Azure Blob storage before.
I love using nLog
I now use Serilog with an nLog sink (with various targets as required) :)

I believe that's what https://github.com/aspnet/AzureIntegration/ does - it wires up logging along with Serilog and pushes log data to tables/blobs/wherever.

There isn't much in the way of guidance tho for the new package. cc/ @Rick-Anderson @danroth27 @spboyer

Thanks all, I've found an simple trick for azure app ,see https://github.com/aspnet/Logging/tree/dev/src , just add the package "Microsoft.Extensions.Logging.AzureAppServices": "1.0.0-preview1-final" and update related dependencies,
add the azure diagnostics in startup.cs like this :
loggerFactory.AddAzureWebAppDiagnostics();   // for default setting.
or
loggerFactory.AddAzureWebAppDiagnostics(new AzureAppServicesDiagnosticsSettings( ...));   // add custom setting.
And enable the diagnostics log on azure, both logging on blob and file are work well. No need for any
extra configuration. :)

authors: DamianEdwards Eilon GuardRex PureKrome Sharpeli Tratcher davidebbo moozzyk muratg


text:
Lower integration test timeouts.

Under some failure conditions test requests can take 100s to timeout, and then they are retried 60 times for a total of 1.3 hours per test failure. This can cause the entire test pass to time out. Lowering this to a maximum of 5s per request, and 30 retires, for a maximum of 2.5 minutes per test failure.
@muratg

:shipit:

authors: Tratcher muratg


text:
Flaky test: TestInvalidRequestLines

As seen here.
System.Net.Internals.SocketExceptionFactory+ExtendedSocketException : A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 127.0.0.1:4514

cc @Tratcher @JunTaoLuo

There are no recorded failures remaining for this test. Closing.

authors: Tratcher muratg ryanbrandenburg

repo: aspnet/KestrelHttpServer


text:
Suppress failures to add user secrets

Two things can go wrong:

Assembly.Load failures if env.ApplicationName does not correspond to a valid assembly
No UserSecretsIdAttribute on the assembly

Resolves #60

Assembly.Load failures if env.ApplicationName does not correspond to a valid assembly

Super rare. Just let it explode. Other parts of the stack try to Load(env.ApplicationName) already so don't bother.

No UserSecretsIdAttribute on the assembly

I'd rather add detection using reflection than by catching exceptions. No first chance exceptions in ASP.NET Core! 😄

How about instead we add an optional setting to the .AddUserSecrets call?

How about instead we add an optional setting to the .AddUserSecrets call?

That was my first choice. Make it like the other providers.

A bool to suppress errors?

I was thinking of adding .AddUserSecrets(Assembly assembly, bool optional) and .AddUserSecrets<T>(bool optional)

Yup

K, let's to that. See https://github.com/aspnet/Configuration/pull/654.
I'll open a PR to use the optional = true setting when it's it.

authors: DamianEdwards davidfowl natemcmaster

repo: aspnet/MetaPackages


text:
Transition MVC TagHelpers to use TargetElementAttributes attribute targeting.

Now that TagHelpers can target attributes we should transition our existing TagHelpers to utilize this new "required" attributes functionality.
One example: ValidationSummaryTagHelper shouldn't target "div" elements then no-op if the attribute doesn't exist: It should target the asp-validation-summary attribute on any HTML element.
This should also enable us to no longer have ambiguity between "should I be a tag helper" for all of our tag helpers.

it's likely views would perform better if tag helpers were not created only to no-op.  however we should measure things to confirm this is worthwhile since the MVC tag helpers are doing simple checks that work today.
specifically:

ValidationSummaryTagHelper shouldn't target "div" elements then no-op if the attribute doesn't exist: It should target the asp-validation-summary attribute on any HTML element.

"any" is too broad.  we likely want to target <div> and <span> and that's about it.  in any case, we should strive to preserve the chosen behaviour and limit work on this issue to the implementation choice.  deal with reevaluating the behaviours separately.

This should also enable us to no longer have ambiguity between "should I be a tag helper" ...

could you clarify this statement?  is this another point about changing the current MVC tag helper behaviours?

@DamianEdwards Let us know if you think we need to pull this back into the current milestone.

We should do this now

@dougbu The ambiguity bit I mentioned will drastically improve TagHelper tooling. For instance, today in the pre-bits for TagHelper tooling every div tag is highlighted because of the validation summary maybe being a TagHelper on div elements. Same thing goes for all other TagHelpers.

@NTaylorMullen thanks, that was much clearer

Part 1 - https://github.com/aspnet/Mvc/commit/bfdeda797df054a4ae8a6fa9250e65f07cd63a1e
Part 2 - https://github.com/aspnet/Mvc/commit/e2058905ec30facdf41d1eca2360be3c4b6b7314
Part 3 - https://github.com/aspnet/Mvc/commit/fd5e07dd0323812263b9fc0160ad56be3a4f3f6c

authors: DamianEdwards NTaylorMullen ajaybhargavb danroth27 dougbu

repo: aspnet/Mvc


text:
Add support for friendly routes in pages

From https://github.com/aspnet/Mvc/issues/5353
Associated with each page is an application model type similar to ControllerModel. We'd build on top of this to provide simple runtime configuration of routes. For instance, to configure an additional route to the /Catalog/Books.cshtml, here's what the Startup code might look like:
services
    .AddMvc()
    .AddRazorPages(options =>
    {
        options.AddPageRoute("Catalog/Books", Books/{id?}");
    });

@DamianEdwards are you ok inverting the order of parameters or would you rather keep it to mirror System.Web?

@pranavkm whatever order makes the most sense in the scope of ASP.NET Core MVC, nothing else.

Great. We'll also call this method AddPageRoute since it makes it clear that it's additive and does not replace existing routes.

FYI @mikebrind

authors: DamianEdwards pranavkm


text:
Update docs to clarify differences between Challenge vs Forbid scenarios

The current documentation doesn't provide details about how exactly the challenge and forbid action results get processed internally and how those are different.
Please run the updated documents with @danroth27.

This issue was moved to aspnet/Docs#6418


text:
Correct evaluation of expression result in GenerateSelect()

#1468
Always use ModelExplorer in <select/>, DropDownListFor() and ListBoxFor() cases
allows evaluation of more-complex expressions
Use ViewData.Model in DropDownList() and ListBox() template cases
ViewData was previously ignored in these cases

nit: change ViewDataDictionary.Eval() to return Model if expression is null or empty

now throw on null or empty expression name in ViewDataEvaluator.Eval()
simplifies some of the higher-level code
no change to selectList fallback; Model incorrect for that case
no change to GenerateRadioButton(); would change behaviour unrelated to #1468
this helper uses incorrect ViewData lookup text, see #1487

:watch: for tests.

:shipit: once @pranavkm or someone else can confirm the smaller implications.

:shipit:

ae4cafc002c8475d116b3c5c0be75fe9deb2cb11

authors: NTaylorMullen dougbu rynowak


text:
[Cookies/Identity] ValidateIdentity => SignIn => ValidateIdentity infinite loop

Looks like the new design of immediate sign in breaks the old way that identity checking the security stamp.  It was registering a Identity validator, and then calling sign in with the new identity.  SignIn is applied immediately now so this triggers an infinite loop...weee
@Tratcher

b9f152ebb1c37845a89889ab7ae80a1395a40455

repo: aspnet/Security


text:
I can't install Sklearn to use ASREVIEW extensions

I'm trying to install an extension, but when I run the installation and it searches for the sklearn library, an error occurs that interrupts the process.
To Reproduce
Steps to reproduce the problem:

Access the terminal and run the installation command:
pip install git+https://github.com/asreview/asreview-multilingual-feature-extractor.git

Execution result:

`PS C:\WINDOWS\system32> pip install git+https://github.com/asreview/asreview-multilingual-feature-extractor.git
Collecting git+https://github.com/asreview/asreview-multilingual-feature-extractor.git
Cloning https://github.com/asreview/asreview-multilingual-feature-extractor.git to c:\users\joaov\appdata\local\temp\pip-req-build-zli54kuk
Running command git clone --filter=blob:none --quiet https://github.com/asreview/asreview-multilingual-feature-extractor.git 'C:\Users\joaov\AppData\Local\Temp\pip-req-build-zli54kuk'
Resolved https://github.com/asreview/asreview-multilingual-feature-extractor.git to commit 0a017c02c8ca8bf262bd0616007a57f7c51f8e09
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Collecting sklearn (from asreview-multilingual-feature-extractor==0.1)
Using cached sklearn-0.0.post12.tar.gz (2.6 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [15 lines of output]
The 'sklearn' PyPI package is deprecated, use 'scikit-learn'
rather than 'sklearn' for pip commands.
  Here is how to fix this error in the main use cases:
  - use 'pip install scikit-learn' rather than 'pip install sklearn'
  - replace 'sklearn' by 'scikit-learn' in your pip requirements files
    (requirements.txt, setup.py, setup.cfg, Pipfile, etc ...)
  - if the 'sklearn' package is used by one of your dependencies,
    it would be great if you take some time to track which package uses
    'sklearn' instead of 'scikit-learn' and report it to their issue tracker
  - as a last resort, set the environment variable
    SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL=True to avoid this error

  More information is available at
  https://github.com/scikit-learn/sklearn-pypi-package
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
PS C:\WINDOWS\system32>`

Version information

OS: Windows 11
Browser: Edge
ASReview version: 1.63

Additional context
I need the sklearn package to perform some functions such as using CNN.

Hi @JoaoVictorNH,
Thank you for the elaborate explanation. This is an issue with the asreview multilingual feature extractor, not asreview itself.
@J535D165 could you move this issue to the linked repo?

Hi @JoaoVictorNH, This issue was fixed in the linked repository, PR I will close this issue.

authors: JoaoVictorNH timovdk

repo: asreview/asreview


text:
Sends OTR events to browser via socket

WIP do not review at the moment

Wrong base, closing.

repo: astorije/shout

license: mit

license_source: bigquery


text:
C414 --fix is also unsafe for sorted(reversed(iterable)), and other issues encountered when comparing with shed

C414 is marked as unsafe fix, but only because of dropping comments: https://docs.astral.sh/ruff/rules/unnecessary-double-cast-or-process/#fix-safety
EDIT: I noticed now that C413 has an extensive warning about safety with regards to stable sorting https://docs.astral.sh/ruff/rules/unnecessary-call-around-sorted/#fix-safety - so the fix is perhaps just that it should be copied over?
But it also breaks sorting stability in some cases, autofixing sorted(reversed(iterable)) to sorted(iterable).
full shell command:
$ ruff check --select=C414 --fix --unsafe-fixes --isolated - <<< 'sorted(reversed(iterable))'
sorted(iterable)
Found 1 error (1 fixed, 0 remaining).

ruff version: 0.3.0
platform: linux
And a full minimal example where the problem is demonstrated. Assertions pass before autofixing with ruff, but fail afterwards.
from __future__ import annotations
from dataclasses import dataclass
@dataclass
class MyClass:
    a: int
    b: int
    def __lt__(self, other: MyClass) -> bool:
        return self.a < other.a

first = MyClass(1, 1)
second = MyClass(1, 2)

# ruff will remove the reversed call in the line below, breaking the assertion
assert sorted(reversed((first, second))) == [second, first]
assert sorted((first, second)) == [first, second]

Found in the process of replacing some of sheds libcst code mods with ruff https://github.com/Zac-HD/shed/pull/105
CodeMod in question: https://github.com/Zac-HD/shed/blob/692a429bff19c3e1a798b97cb45396160dc138eb/src/shed/_codemods.py#L275-L315
Unrelated to this specific issue: That codemod also handles cases of combining reverse:
sorted(sorted(iterable, reverse=True), reverse=False) -> sorted(iterable, reverse=False)
sorted(sorted(iterable, reverse=False), reverse=True) -> sorted(iterable, reverse=True)

I'll continue mentioning some related things popping up, can open dedicated issues for them later if you want:
C415 does not have an autofix in ruff, but does in shed. So you might be interested in copying the implementation/logic: https://github.com/Zac-HD/shed/blob/692a429bff19c3e1a798b97cb45396160dc138eb/src/shed/_codemods.py#L317-L330

E711 docs states 'fix is always available' but it's marked as unsafe
$ ruff check --select=E711 --isolated --fix-only - <<< 'z == None'
z == None
No errors fixed (1 fix available with `--unsafe-fixes`).

The "Use instead" in the example also only contains one of the two input examples in the Example: https://docs.astral.sh/ruff/rules/none-comparison/#example

shed has a custom codemod for handling empty collections passed to builtins, which isn't fully covered by ruff - likely because flake8-comprehensions doesn't cover them either. (I have not dug into if they've been rejected by flake8-comprehensions, or just not considered)
# handled by ruff
list([]) # C410
list(()) # C410

dict({}) # C418
dict([]) # C406
dict(()) # C406

tuple([]) # C409
tuple(()) # C409

# ruff does not raise any errors
list({})
list("")
dict("")
tuple({})
tuple("")

there's two checks for assert False being disallowed (PT015 and B011), but none for assert True.

PT018 docs also mention nothing about being unsafe
$ ruff check --select=PT018 --fix - <<< 'assert a and b'
assert a and b
-:1:1: PT018 Assertion should be broken down into multiple parts
Found 1 error.
No fixes available (1 hidden fix can be enabled with the `--unsafe-fixes` option).

and it very much is, doesn't even handle the trivial case of a single trailing comment:
$ ruff check --select=PT018 --fix --unsafe-fixes - <<< 'assert a and b # comment'
assert a
assert b
Found 1 error (1 fixed, 0 remaining).

shed has a very chonky, afaik fully comment-safe, autofix for it. Since you don't use libcst, and it being very much tailored to it wrt comments, it maybe isn't of that much use to you though https://github.com/Zac-HD/shed/blob/692a429bff19c3e1a798b97cb45396160dc138eb/src/shed/_codemods.py#L476-625

Thanks! Heads up that it's not defined that removing comments merits an unsafe fix, there's discussion here that needs a decision: https://github.com/astral-sh/ruff/issues/9790.

Good to know! Regardless of the decision though, it seems you need a pass (and/or automated test) to make sure that checks that require --unsafe-fixes are documented as such.

SIM117 joins the ranks of checks not being documented as requiring --unsafe-fixes, and it appears to give up on collapsing once it hits the line-length limit (regardless of python version). ruff format handles multi-line withs perfectly.
before
with make_context_manager() as cm1:
    with make_context_manager() as cm2:
        with make_context_manager() as cm3:
            with make_context_manager() as cm4:
                pass

after running ruff --select=SIM117 --unsafe-fixes --fix --target-version=py312 --isolated foo.py
with make_context_manager() as cm1, make_context_manager() as cm2:
    with make_context_manager() as cm3:
        with make_context_manager() as cm4:
            pass

Shed codemod that handles cases like the above: https://github.com/Zac-HD/shed/blob/692a429bff19c3e1a798b97cb45396160dc138eb/src/shed/_codemods.py#L688-L749
Inspired by pybetter: https://github.com/lensvol/pybetter/blob/master/pybetter/transformers/nested_withs.py

SIM101 and PLR1701 seems to be the exact same check, except the former requires --unsafe-fixes while the latter doesn't...
which is entirely backward because PLR1701 does more than just remove comments:
$ ruff check --select=PLR1701 --fix - <<< 'isinstance(x, y) or CRITICAL_CALL() or isinstance(x, z)'
isinstance(x, (y, z))
Found 1 error (1 fixed, 0 remaining).

SIM101 does not trigger an error on the above code, which is the correct behaviour.
They funnily enough also differ on whether they sort(?) the types:
$ source='isinstance(x, int) or isinstance(x, float)'

$ ruff check --select=SIM101 --fix --unsafe-fixes - <<< $source
isinstance(x, (int, float))
Found 1 error (1 fixed, 0 remaining).

$ ruff check --select=PLR1701 --fix - <<< $source
isinstance(x, (float, int))
Found 1 error (1 fixed, 0 remaining).

PLR1701 should probably be removed.

I'll also try to document the remaining autofixes in shed, several of which has no checks in other flake8 plugins, so ruff can consider adding them as checks and potentially fixes without having to dig straight into the source code.

Thanks!

Quick draft: https://github.com/jakkdl/shed/blob/use_ruff/CODEMODS.md

authors: charliermarsh jakkdl

repo: astral-sh/ruff


text:
Ability to add noqa for individual rules

Would be nice if --add-noqa could take an optional argument to only add those ignores for a given rule, and not globally.

Thanks!


text:
red-knot: support narrowing for bool(E)

Resolves https://github.com/astral-sh/ruff/issues/14547 by delegating narrowing to E for bool(E) where E is some expression.
This change does not include other builtin class constructors which should also work in this position, like int(..) or float(..), as the original issue does not mention these. It should be easy enough to add checks for these as well if we want to.
I don't see a lot of markdown tests for malformed input, maybe there's a better place for the no args and too many args cases to go?
I did see after the fact that it looks like this task was intended for a new hire.. my apologies. I got here from https://github.com/astral-sh/ruff/issues/13694, which is marked help-wanted.

Just a note for future: this issue was assigned to me, and not marked "help wanted", because I created it specifically as a ramp-up task for someone joining the Astral team this week :) It's totally fine that you took it on (thanks for the contribution!), but in future it's best to check if an issue is assigned to someone before starting work on it, and if so, comment on the issue to check if you can take it over without duplicating someone's work-in-progress.

authors: carljm connorskees


text:
--index-url from requirements.txt is ignored

--index-url is ignored in requirements.txt, no issue with --extra-index-url parameter.
Look like it's related to the way IndexUrl argument is used. This argument is always initialized with a value (here) and combine always keep the previous value if present (here).
If I invert the expression in combine, my --index-url in requirements.txt is correctly used; but this is maybe not the expected way to fix it because command line parameter (if really defined) should take precedence ?
This affect both pip install and pip  compile commands.
Fail with this requirements.txt:
--index-url https://my-pip-index.org/artifactory/api/pypi/pypi-custom-release/simple/

my-custom-package

Work with:
--extra-index-url https://my-pip-index.org/artifactory/api/pypi/pypi-custom-release/simple/

my-custom-package

With both commands:
uv -v --no-cache pip install requirements.txt
uv -v --no-cache pip compile requirements.in

To set the --index-url, the current workaround is to always set in on command line like:
uv -v --no-cache pip install --index-url https://my-pip-index.org/artifactory/api/pypi/pypi-custom-release/simple/ requirements.txt

(description edited because  it's more related to arguments default values rather than IndexLocations default values)

It is possible to add private PyPI in the pyproject.toml in a standardized way that uv understands? That is quite imporant in many corporate settings.  poetry supports this via the non-standard [[tool.poetry.source]] so that works well for corporations.

Not yet, but we will support persistent configuration of registries in the future.

Thanks for the quick fix

Not yet, but we will support persistent configuration of registries in the future.

@zanieb is there a tracking issue for that feature I can subscribe to?

authors: PetterS framillien zanieb

repo: astral-sh/uv


text:
UV_INDEX_URL with AWS CodeArtifact index consistently fails on large packages

I have a project with a ton of dependencies, and an AWS CodeArtifact PyPI server that I host my dependencies in. When I use it as my index URL, I am consistently getting failures as compared to when I do not.
Related:

https://github.com/astral-sh/uv/issues/1426
https://github.com/astral-sh/uv/issues/2586
https://github.com/astral-sh/uv/issues/3514

requirements.txt:
nvidia-cublas-cu12==12.1.3.1
nvidia-cuda-cupti-cu12==12.1.105
nvidia-cuda-nvrtc-cu12==12.1.105
nvidia-cuda-runtime-cu12==12.1.105
nvidia-cudnn-cu12==8.9.2.26
nvidia-cufft-cu12==11.0.2.54
nvidia-curand-cu12==10.3.2.106
nvidia-cusolver-cu12==11.4.5.107
nvidia-cusparse-cu12==12.1.0.106
nvidia-nccl-cu12==2.20.5
nvidia-nvjitlink-cu12==12.5.40
nvidia-nvtx-cu12==12.1.105

The above packages are the main offenders. Notably, they are all large. To pick a few (the ones that appear in the error messages):

nvidia-nccl-cu12==2.20.5 is 176.2 MB
nvidia-cusparse-cu12==12.1.0.106 is 196.0 MB
nvidia-cusolver-cu12==11.4.5.107 is 124.2 MB

To reproduce:
$ rm -rf ~/.cache/uv
$ conda create -n uvtest python=3.10 -y
$ conda activate uvtest
$ pip install uv
...
Installing collected packages: uv
Successfully installed uv-0.2.13
$ aws sso login
$ ...
$ export UV_INDEX_URL="https://aws:${CODEARTIFACT_AUTH_TOKEN}@${CODEARTIFACT_DOMAIN}-${AWS_ACCOUNT_ID}.d.codeartifact.${AWS_PIP_REGION}.amazonaws.com/pypi/${CODEARTIFACT_REPO}"
$ export UV_HTTP_TIMEOUT=60
$ uv pip install -r requirements.txt
...
error: Failed to download distributions
  Caused by: Failed to fetch wheel: nvidia-nccl-cu12==2.20.5
  Caused by: Failed to extract archive
  Caused by: error decoding response body
  Caused by: request or response body error
  Caused by: error reading a body from connection
  Caused by: end of file before message length reached

a different time:
$ uv pip install -r requirements.txt
error: Failed to download distributions
  Caused by: Failed to fetch wheel: nvidia-cusparse-cu12==12.1.0.106
  Caused by: Failed to extract archive
  Caused by: error decoding response body
  Caused by: request or response body error
  Caused by: error reading a body from connection
  Caused by: peer closed connection without sending TLS close_notify: https://docs.rs/rustls/latest/rustls/manual/_03_howto/index.html#unexpected-eof

a different time:
$ uv pip install -r requirements.txt
error: Failed to download distributions
  Caused by: Failed to fetch wheel: nvidia-cusolver-cu12==11.4.5.107
  Caused by: Failed to extract archive
  Caused by: error decoding response body
  Caused by: request or response body error
  Caused by: error reading a body from connection
  Caused by: peer closed connection without sending TLS close_notify: https://docs.rs/rustls/latest/rustls/manual/_03_howto/index.html#unexpected-eof

I do not see these errors when running with --verbose??

I got this today for a random big package, installed from a self-hosted Pypi. It would error on random dependencies from the big package, same error message: Caused by: peer closed connection without sending TLS close_notify: https://docs.rs/rustls/latest/rustls/manual/_03_howto/index.html#unexpected-eof

Lemme see if the retries I just added cover this case.

Okay I believe this is a form of UnexpectedEof so the error itself should be covered. I'll test it.

@charliermarsh I love you

Ok based on my testing this should be solved by #9253. If you see it after the next release, ping note it here and I'll re-open.


text:
@latest support?

I'm coming from a poetry background here and one thing I regularly need to do is upgrade multiple packages to the latest compatible version, while leaving others untouched. With poetry, this is poetry show -o to list packages where updates are available, and then I can poetry add {package}@latest to upgrade the ones I want to upgrade - after each upgrade, I then run the test suite to make sure nothing has broken (so I definitely don't want to upgrade everything all at once).
I've been trying to do this on a project I've converted to uv but there doesn't seem to be a simple way to do this. These are what I've found in the docs...

uv add 'httpx>0.1.0' --upgrade-package httpx is incredibly verbose and requires me to look up what bounds I want to give it - ie: uv add httpx --upgrade-package httpx does nothing. Doing this for a lot of packages takes considerably longer than the poetry way.
uv lock --upgrade-package requests only works with loose constraints in the pyproject.toml so I'm having to go in and hand edit the pyproject.toml in order to test the project with the latest version

Have I missed something in the docs? Is support for uv add {package}@latest or similar on the roadmap at all?

Can you explain why uv lock --upgrade-package requests isn't working here? Do you have an upper-bound on your package or something?

Hey @charliermarsh - yes, exactly that. The pyproject.toml had, if I remember correctly,~= some version. I'm bound to be doing the above flows while switching another project over to uv soon so I'll post a more concrete example soon.
PS. Thank you so much for ruff and uv, they're the most exciting things to happen to Python in years.

authors: charliermarsh drcongo


text:
UV lists python interpreters but can't use them!

I'm on version uv 0.5.6 (b70c4f30e 2024-12-03) on windows
uv sees my python interpreters from the windows registry
C:\Temp>uv python list
cpython-3.13.0+freethreaded-windows-x86_64-none    <download available>
cpython-3.12.7-windows-x86_64-none                 <download available>
cpython-3.12.2-windows-x86_64-none                 D:\apps\Python\Python312\python.exe
cpython-3.11.10-windows-x86_64-none                <download available>
cpython-3.10.15-windows-x86_64-none                <download available>
cpython-3.9.20-windows-x86_64-none                 <download available>
cpython-3.9.13-windows-x86_64-none                 D:\apps\python\Python39\python.exe
cpython-3.9.12-windows-x86_64-none                 C:\ProgramData\Miniconda3\python.exe
cpython-3.8.20-windows-x86_64-none                 <download available>
cpython-3.7.9-windows-x86_64-none                  <download available>
cpython-3.7.6-windows-x86_64-none                  C:\apps\python37\python.exe
pypy-3.10.14-windows-x86_64-none                   <download available>
pypy-3.9.19-windows-x86_64-none                    <download available>
pypy-3.8.16-windows-x86_64-none                    <download available>
pypy-3.7.13-windows-x86_64-none                    <download available>

But when I try and use one of them uv complains it does not exists
C:\Temp>uv venv --python 3.9.13 orion --seed --no-python-downloads
  x No interpreter found for Python 3.9.13 in managed installations, search path, or registry

I think the uv venv command does not use the same discover mechanism as the uv list

That's surprising. Can you share the --verbose logs for uv venv? It may be helpful to include trace logs which include additional information about interpreter selection RUST_LOG=uv=trace

sure, here's the verbose uv venv output
C:\Temp>uv venv --python 3.9.13 orion --seed --no-python-downloads -vvv
    0.000032s ←[1;34mDEBUG←[0m ←[2muv←[0m uv 0.5.6 (b70c4f30e 2024-12-03)
    0.001042s ←[1;34mDEBUG←[0m ←[2muv::commands::project←[0m Using Python request `3.9.13` from explicit request
    0.002170s ←[1;34mDEBUG←[0m ←[2muv_python::discovery←[0m Searching for Python 3.9.13 in managed installations, search path, or registry
    0.004699s ←[1;34mDEBUG←[0m ←[2muv_python::discovery←[0m Searching for managed installations at `C:\Users\mjamaa\AppData\Roaming\uv\python`
    0.008461s ←[1;34mDEBUG←[0m ←[2muv_python::discovery←[0m Found `cpython-3.12.2-windows-x86_64-none` at `D:\apps\Python\Python312\python.exe` (search path)
    0.008620s ←[1;34mDEBUG←[0m ←[2muv_python::discovery←[0m Skipping interpreter at `D:\apps\Python\Python312\python.exe` from search path: does not satisfy request `3.9.13`
    0.012016s ←[1;34mDEBUG←[0m ←[2muv_python::py_launcher←[0m Python interpreter in the registry is not executable: `Software\Python\PythonCore\3.9
  x No interpreter found for Python 3.9.13 in managed installations, search path, or registry

I'm running into a similar issue on macOS:
% uv --version
uv 0.5.6 (Homebrew 2024-12-03)
% cat ~/.config/uv/uv.toml
python-preference = "only-system"

% uv python list
cpython-3.13.0-macos-aarch64-none    /opt/homebrew/opt/python@3.13/bin/python3.13 -> ../Frameworks/Python.framework/Versions/3.13/bin/python3.13
cpython-3.12.8-macos-aarch64-none    /opt/homebrew/opt/python@3.12/bin/python3.12 -> ../Frameworks/Python.framework/Versions/3.12/bin/python3.12
cpython-3.9.6-macos-aarch64-none     /Applications/Xcode.app/Contents/Developer/usr/bin/python3 -> ../../Library/Frameworks/Python3.framework/Versions/3.9/bin/python3
% uv python find '==3.13.0'
/opt/homebrew/opt/python@3.13/bin/python3.13
% uv python find '==3.12.8'
error: No interpreter found for Python ==3.12.8 in virtual environments or search path

Or with more logging:
% RUST_LOG=uv=trace uv python list
DEBUG uv 0.5.6 (Homebrew 2024-12-03)
DEBUG Searching for any Python interpreter in search path
TRACE Searching PATH for executables: python, python3, cpython, cpython3, pypy, pypy3, graalpy, graalpy3
TRACE Checking `PATH` directory for interpreters: /opt/homebrew/bin
TRACE Found possible Python executable: /opt/homebrew/bin/python3
TRACE Cached interpreter info for Python 3.13.0, skipping probing: /opt/homebrew/bin/python3
DEBUG Found `cpython-3.13.0-macos-aarch64-none` at `/opt/homebrew/bin/python3` (search path)
TRACE Found possible Python executable: /opt/homebrew/bin/python3.12
TRACE Cached interpreter info for Python 3.12.8, skipping probing: /opt/homebrew/bin/python3.12
DEBUG Found `cpython-3.12.8-macos-aarch64-none` at `/opt/homebrew/bin/python3.12` (search path)
TRACE Found possible Python executable: /opt/homebrew/bin/python3.13
TRACE Cached interpreter info for Python 3.13.0, skipping probing: /opt/homebrew/bin/python3.13
DEBUG Found `cpython-3.13.0-macos-aarch64-none` at `/opt/homebrew/bin/python3.13` (search path)
TRACE Checking `PATH` directory for interpreters: /opt/homebrew/sbin
TRACE Checking `PATH` directory for interpreters: /usr/local/bin
TRACE Checking `PATH` directory for interpreters: /System/Cryptexes/App/usr/bin
TRACE Checking `PATH` directory for interpreters: /usr/bin
TRACE Found possible Python executable: /usr/bin/python3
TRACE Querying interpreter executable at /usr/bin/python3
DEBUG Found `cpython-3.9.6-macos-aarch64-none` at `/usr/bin/python3` (search path)
TRACE Checking `PATH` directory for interpreters: /bin
TRACE Checking `PATH` directory for interpreters: /usr/sbin
TRACE Checking `PATH` directory for interpreters: /sbin
TRACE Checking `PATH` directory for interpreters: /Library/Apple/usr/bin
TRACE Checking `PATH` directory for interpreters: /Users/aloenr01/.cargo/bin
TRACE Checking `PATH` directory for interpreters: /Applications/iTerm.app/Contents/Resources/utilities
cpython-3.13.0-macos-aarch64-none    /opt/homebrew/opt/python@3.13/bin/python3.13 -> ../Frameworks/Python.framework/Versions/3.13/bin/python3.13
cpython-3.12.8-macos-aarch64-none    /opt/homebrew/opt/python@3.12/bin/python3.12 -> ../Frameworks/Python.framework/Versions/3.12/bin/python3.12
cpython-3.9.6-macos-aarch64-none     /Applications/Xcode.app/Contents/Developer/usr/bin/python3 -> ../../Library/Frameworks/Python3.framework/Versions/3.9/bin/python3
% RUST_LOG=uv=trace uv python find '==3.12.8'
DEBUG uv 0.5.6 (Homebrew 2024-12-03)
DEBUG Using Python request `==3.12.8` from explicit request
DEBUG Searching for Python ==3.12.8 in virtual environments or search path
TRACE Searching PATH for executables: python3, python
TRACE Checking `PATH` directory for interpreters: /opt/homebrew/bin
TRACE Found possible Python executable: /opt/homebrew/bin/python3
TRACE Cached interpreter info for Python 3.13.0, skipping probing: /opt/homebrew/bin/python3
DEBUG Found `cpython-3.13.0-macos-aarch64-none` at `/opt/homebrew/bin/python3` (search path)
DEBUG Skipping interpreter at `/opt/homebrew/opt/python@3.13/bin/python3.13` from search path: does not satisfy request `==3.12.8`
TRACE Checking `PATH` directory for interpreters: /opt/homebrew/sbin
TRACE Checking `PATH` directory for interpreters: /usr/local/bin
TRACE Checking `PATH` directory for interpreters: /System/Cryptexes/App/usr/bin
TRACE Checking `PATH` directory for interpreters: /usr/bin
TRACE Found possible Python executable: /usr/bin/python3
TRACE Querying interpreter executable at /usr/bin/python3
DEBUG Found `cpython-3.9.6-macos-aarch64-none` at `/usr/bin/python3` (search path)
DEBUG Skipping interpreter at `/Applications/Xcode.app/Contents/Developer/usr/bin/python3` from search path: does not satisfy request `==3.12.8`
TRACE Checking `PATH` directory for interpreters: /bin
TRACE Checking `PATH` directory for interpreters: /usr/sbin
TRACE Checking `PATH` directory for interpreters: /sbin
TRACE Checking `PATH` directory for interpreters: /Library/Apple/usr/bin
TRACE Checking `PATH` directory for interpreters: /Users/aloenr01/.cargo/bin
TRACE Checking `PATH` directory for interpreters: /Applications/iTerm.app/Contents/Resources/utilities
error: No interpreter found for Python ==3.12.8 in virtual environments or search path

It looks like the uv python list code does this:
https://github.com/astral-sh/uv/blob/3aaa9594be4727fb4a6260b1cc5782eb66e47284/crates/uv-python/src/discovery.rs#L499-L501
where the find_all_minor means it can pick up on /opt/homebrew/bin/python3.12.
But when asking for ==3.12.8 specifically, it doesn't consider that 3.12 could be it:
https://github.com/astral-sh/uv/blob/3aaa9594be4727fb4a6260b1cc5782eb66e47284/crates/uv-python/src/discovery.rs#L579-L581

@aDotInTheVoid that's unrelated — the above issue is related to the Windows registry — could you open a new issue instead?
@meitham There's an error

Python interpreter in the registry is not executable: `Software\Python\PythonCore\3.9

This comes from the check at https://github.com/astral-sh/uv/blob/d0afd10ca4a7c6ebaacbe0a6188eec09d8f47022/crates/uv-python/src/py_launcher.rs#L66-L76
I'm not sure what would cause that, @konstin may know.
Does it work for other Python versions like 3.12?

Can you share the output of Get-ChildItem -Path "HKCU:\Software\Python" -Recurse -Depth 2?
Currently puzzled by how the 3.9.13 is shown in the list but then can't be used, we use the same code path for listing and deciding on which interpreter to execute.

Please see below my registry.  I think I see what the issue is, I have python 3.9.12 (miniconda) and python 3.9.13 (psf) but in the windows registry their patch version is omitted so they both appear as 3.9.  Though one was installed by admin so it went into current machine, and the other is in current user.
`
Hive: HKEY_CURRENT_USER\Software\Python

Name                           Property

PyLauncher                     InstallDir     : C:\Users\mjamaa\AppData\Local\Programs\Python\Launcher\
AssociateFiles : 1
(default)      : C:\Users\mjamaa\AppData\Local\Programs\Python\Launcher\py.exe
PythonCore                     DisplayName : Python Software Foundation
SupportUrl  : https://www.python.org/
Hive: HKEY_CURRENT_USER\Software\Python\PythonCore

Name                           Property

3.12                           DisplayName     : Python 3.12 (64-bit)
SupportUrl      : https://www.python.org/
Version         : 3.12.2
SysVersion      : 3.12
SysArchitecture : 64bit
Hive: HKEY_CURRENT_USER\Software\Python\PythonCore\3.12

Name                           Property

Help
Idle                           (default) : D:\apps\Python\Python312\Lib\idlelib\idle.pyw
IdleShortcuts                  (default) : 1
InstalledFeatures              Shortcuts    : 3.12.2150.0
exe          : 3.12.2150.0
dev          : 3.12.2150.0
lib          : 3.12.2150.0
test         : 3.12.2150.0
doc_shortcut : 3.12.2150.0
doc          : 3.12.2150.0
tcltk        : 3.12.2150.0
pip          : 3.12.2150.0
path         : 3.12.2150.0
InstallPath                    (default)              : D:\apps\Python\Python312\
ExecutablePath         : D:\apps\Python\Python312\python.exe
WindowedExecutablePath : D:\apps\Python\Python312\pythonw.exe
PythonPath                     (default) : D:\apps\Python\Python312\Lib;D:\apps\Python\Python312\DLLs\
Hive: HKEY_CURRENT_USER\Software\Python\PythonCore

Name                           Property

3.7                            DisplayName     : Python 3.7 (64-bit)
SupportUrl      : http://www.python.org/
Version         : 3.7.6
SysVersion      : 3.7
SysArchitecture : 64bit
Hive: HKEY_CURRENT_USER\Software\Python\PythonCore\3.7

Name                           Property

Help
Idle                           (default) : C:\apps\python37\Lib\idlelib\idle.pyw
IdleShortcuts                  (default) : 1
InstalledFeatures              dev          : 3.7.6150.0
Shortcuts    : 3.7.6150.0
exe          : 3.7.6150.0
lib          : 3.7.6150.0
test         : 3.7.6150.0
doc_shortcut : 3.7.6150.0
doc          : 3.7.6150.0
tools        : 3.7.6150.0
tcltk        : 3.7.6150.0
pip          : 3.7.6150.0
InstallPath                    (default)              : C:\apps\python37\
ExecutablePath         : C:\apps\python37\python.exe
WindowedExecutablePath : C:\apps\python37\pythonw.exe
PythonPath                     (default) : C:\apps\python37\Lib;C:\apps\python37\DLLs\
Hive: HKEY_CURRENT_USER\Software\Python\PythonCore

Name                           Property

3.9                            DisplayName     : Python 3.9 (64-bit)
SupportUrl      : https://www.python.org/
Version         : 3.9.13
SysVersion      : 3.9
SysArchitecture : 64bit
Hive: HKEY_CURRENT_USER\Software\Python\PythonCore\3.9

Name                           Property

Help
Idle                           (default) : D:\apps\python\Python39\Lib\idlelib\idle.pyw
IdleShortcuts                  (default) : 1
InstalledFeatures              dev          : 3.9.13150.0
Shortcuts    : 3.9.13150.0
exe          : 3.9.13150.0
lib          : 3.9.13150.0
test         : 3.9.13150.0
doc_shortcut : 3.9.1150.0
doc          : 3.9.1150.0
tools        : 3.9.13150.0
tcltk        : 3.9.13150.0
pip          : 3.9.13150.0
InstallPath                    (default)              : D:\apps\python\Python39\
ExecutablePath         : D:\apps\python\Python39\python.exe
WindowedExecutablePath : D:\apps\python\Python39\pythonw.exe
Modules                        (default) :
PythonPath                     (default) : D:\apps\python\Python39\Lib;D:\apps\python\Python39\DLLs\
`
and
`
Hive: HKEY_LOCAL_MACHINE\Software\Python

Name                           Property

ContinuumAnalytics             DisplayName : Continuum Analytics, Inc.
SupportUrl  : https://github.com/continuumio/anaconda-issues
Hive: HKEY_LOCAL_MACHINE\Software\Python\ContinuumAnalytics

Name                           Property

Anaconda39-64                  DisplayName     : Anaconda py39_4.12.0
SupportUrl      : https://github.com/continuumio/anaconda-issues
Version         : py39_4.12.0
SysVersion      : 3.9
SysArchitecture : 64bit
Hive: HKEY_LOCAL_MACHINE\Software\Python\ContinuumAnalytics\Anaconda39-64

Name                           Property

Help
InstallPath                    (default)              : C:\ProgramData\Miniconda3
ExecutablePath         : C:\ProgramData\Miniconda3\python.exe
WindowedExecutablePath : C:\ProgramData\Miniconda3\pythonw.exe
Modules                        (default) :
PythonPath                     (default) : C:\ProgramData\Miniconda3\Lib;C:\ProgramData\Miniconda3\DLLs
Hive: HKEY_LOCAL_MACHINE\Software\Python

Name                           Property

PythonCore
Hive: HKEY_LOCAL_MACHINE\Software\Python\PythonCore

Name                           Property

3.9
Hive: HKEY_LOCAL_MACHINE\Software\Python\PythonCore\3.9

Name                           Property

Help
InstallPath                    (default) : C:\ProgramData\Miniconda3
Modules                        (default) :
PythonPath                     (default) : C:\ProgramData\Miniconda3\Lib;C:\ProgramData\Miniconda3\DLLs
`

Thank you for fixing this, and special thanks for fixing the colors issue ;-)

authors: aDotInTheVoid konstin meitham zanieb