Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion documentation/general/dotnet-run-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,9 @@ We do not limit these directives to appear only in entry point files because it
- which also makes it possible to share it independently or symlink it to multiple script folders,
- and it's similar to `global using`s which users usually put into a single file but don't have to.

We disallow duplicate `#:` directives to allow us design some deduplication mechanism in the future.
We disallow duplicate `#:` directives (except `#:project` and `#:ref`) to allow us to design some deduplication mechanism in the future.
Specifically, directives are considered duplicate if their type and name (case insensitive) are equal.
`#:project` and `#:ref` duplicates are allowed because MSBuild allows duplicate `<ProjectReference />` items.
Later with deduplication, separate "self-contained" utilities could reference overlapping sets of packages
even if they end up in the same compilation.
For example, properties could be concatenated via `;`, more specific package versions could override less specific ones.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,19 @@ public static void FindLeadingDirectives(

if (CSharpDirective.Parse(context) is { } directive)
{
// If the directive is already present, report an error.
if (deduplicated.TryGetValue(directive, out var existingDirective))
// Duplicate #:project and #:ref directives are allowed (MSBuild can handle that).
if (directive is not (CSharpDirective.Project or CSharpDirective.Ref))
{
var typeAndName = $"#:{existingDirective.GetType().Name.ToLowerInvariant()} {existingDirective.Name}";
context.ReportError(directive.Info.Span, string.Format(FileBasedProgramsResources.DuplicateDirective, typeAndName));
}
else
{
deduplicated.Add(directive, directive);
// If the directive is already present, report an error.
if (deduplicated.TryGetValue(directive, out var existingDirective))
{
var typeAndName = $"#:{existingDirective.GetType().Name.ToLowerInvariant()} {existingDirective.Name}";
context.ReportError(directive.Info.Span, string.Format(FileBasedProgramsResources.DuplicateDirective, typeAndName));
}
else
{
deduplicated.Add(directive, directive);
}
}

builder?.Add(directive);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
// Ideally we'd call LoadIntoBufferAsync, but it has no overload that accepts a CancellationToken so we call ReadAsByteArrayAsync instead.
_ = await response.Content.ReadAsByteArrayAsync(cancellationToken).ConfigureAwait(false);

if (await GetAuthenticationAsync(_registryName, scheme, authInfo, cancellationToken).ConfigureAwait(false) is (AuthenticationHeaderValue authHeader, DateTimeOffset expirationTime))
if (await GetAuthenticationAsync(_registryName, scheme!, authInfo, cancellationToken).ConfigureAwait(false) is (AuthenticationHeaderValue authHeader, DateTimeOffset expirationTime))
{
_authenticationHeaders[_registryName] = authHeader;
request.Headers.Authorization = authHeader;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#if NETFRAMEWORK
using System;
using System.Linq;
#endif
#if NET
using System.Diagnostics.CodeAnalysis;
#endif
using System.Text;
using System.Text.Json.Nodes;
using System.Text.RegularExpressions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ private HashSet<Port> GetExposedPorts()
&& property.Value is JsonObject propertyValue
&& ContainerHelpers.TryParsePort(propertyName, out Port? parsedPort, out ContainerHelpers.ParsePortError? _))
{
ports.Add(parsedPort.Value);
ports.Add(parsedPort!.Value);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>$(SdkTargetFramework);$(NetFrameworkToolCurrent)</TargetFrameworks>
<ImplicitUsings Condition="'$(TargetFramework)' != '$(NetFrameworkToolCurrent)'">enable</ImplicitUsings>
<TargetFrameworks>$(SdkTargetFramework)</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>

<TargetsForTfmSpecificBuildOutput>
$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage
</TargetsForTfmSpecificBuildOutput>

<!-- Tell the SDK to generate a deps.json file to be used by .NET SDK MSBuild -->
<GenerateDependencyFile Condition=" '$(TargetFramework)' != '$(NetFrameworkToolCurrent)'">true</GenerateDependencyFile>
<GenerateDependencyFile>true</GenerateDependencyFile>

<!-- Allow the packaging project to use the name `Microsoft.NET.Build.Containers` for the nuget package -->
<Packageid>.</Packageid>
Expand All @@ -26,14 +26,13 @@

<ItemGroup>
<ProjectReference Include="..\..\Cli\Microsoft.DotNet.Cli.Utils\Microsoft.DotNet.Cli.Utils.csproj"
Condition="'$(TargetFrameworkIdentifier)' != '.NETFramework'"
GlobalPropertiesToRemove="PublishDir">
<!-- This is referenced by the core CLI as well so it doesn't need to be redistributed
in the containers task folder. -->
<IncludeAssets>build</IncludeAssets>
<Private>false</Private>
</ProjectReference>
<ProjectReference Include="..\..\Microsoft.Extensions.Logging.MSBuild\Microsoft.Extensions.Logging.MSBuild.csproj" Condition="'$(TargetFrameworkIdentifier)' != '.NETFramework'" />
<ProjectReference Include="..\..\Microsoft.Extensions.Logging.MSBuild\Microsoft.Extensions.Logging.MSBuild.csproj" />
</ItemGroup>

<ItemGroup>
Expand All @@ -44,49 +43,22 @@
</PackageReference>
<PackageReference Include="Nuget.Packaging">
<!-- In the SDK, NuGet is already available in the MSBuild/SDK directory -->
<ExcludeAssets Condition="'$(TargetFrameworkIdentifier)' != '.NETFramework'">runtime</ExcludeAssets>
</PackageReference>
<PackageReference Include="System.Text.Json" ExcludeAssets="runtime" Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
<!-- For the netframework flavor, lock back to a System.Text.Json equal to or older than MSBuild will provide
so it doesn't have to be redistributed. -->
<VersionOverride Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">$(SystemTextJsonToolsetPackageVersion)</VersionOverride>
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETFramework'">
<ItemGroup>
<Compile Include="$(RepoRoot)src\Common\VSHostObject.cs" LinkBase="Common" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Valleysoft.DockerCredsProvider" />

<!-- References that are also carried in the SDK itself so don't need to be redistributed -->
<PackageReference Include="Microsoft.Extensions.Logging" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" ExcludeAssets="runtime" />
</ItemGroup>

<!-- netframework builds manually import files to compile -->
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<Compile Remove="**/*.*" />
<Compile Include="ReferenceParser.cs" />
<Compile Include="KnownStrings.cs" />
<Compile Include="DockerLoadException.cs" />
<Compile Include="Registry/RegistryConstants.cs" />
<Compile Include="Tasks/ParseContainerProperties.cs" />
<Compile Include="Tasks/CreateNewImage.Interface.cs" />
<Compile Include="Tasks/CreateNewImageToolTask.cs" />
<Compile Include="Tasks/ComputeDotnetBaseImageAndTag.cs" />
<Compile Include="ContainerHelpers.cs" />
<Compile Include="netframeworkDefinitions.cs" />
<Compile Include="VSHostObject.cs" />
<Compile Include="Port.cs" />
<Compile Include="Resources\Resource.cs" />
<Compile Include="Resources\Strings.Designer.cs" />
<Compile Include="Globals.cs" />
</ItemGroup>

<!-- core remove files specific to netframework workarounds -->
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETFramework'">
<Compile Remove="Tasks/CreateNewImageToolTask.cs" />
<Compile Remove="netframeworkDefinitions.cs" />
</ItemGroup>

<ItemGroup>
<Compile Update="Resources\Strings.Designer.cs">
<DesignTime>True</DesignTime>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,6 @@ Microsoft.NET.Build.Containers.Tasks.CreateNewImage.BaseRegistry.set -> void
Microsoft.NET.Build.Containers.Tasks.CreateNewImage.Cancel() -> void
Microsoft.NET.Build.Containers.Tasks.CreateNewImage.ContainerEnvironmentVariables.get -> Microsoft.Build.Framework.ITaskItem![]!
Microsoft.NET.Build.Containers.Tasks.CreateNewImage.ContainerEnvironmentVariables.set -> void
Microsoft.NET.Build.Containers.Tasks.CreateNewImage.ContainerizeDirectory.get -> string!
Microsoft.NET.Build.Containers.Tasks.CreateNewImage.ContainerizeDirectory.set -> void
Microsoft.NET.Build.Containers.Tasks.CreateNewImage.ContainerRuntimeIdentifier.get -> string!
Microsoft.NET.Build.Containers.Tasks.CreateNewImage.ContainerRuntimeIdentifier.set -> void
Microsoft.NET.Build.Containers.Tasks.CreateNewImage.ContainerUser.get -> string!
Expand Down Expand Up @@ -245,10 +243,6 @@ Microsoft.NET.Build.Containers.Tasks.CreateNewImage.PublishDirectory.get -> stri
Microsoft.NET.Build.Containers.Tasks.CreateNewImage.PublishDirectory.set -> void
Microsoft.NET.Build.Containers.Tasks.CreateNewImage.RuntimeIdentifierGraphPath.get -> string!
Microsoft.NET.Build.Containers.Tasks.CreateNewImage.RuntimeIdentifierGraphPath.set -> void
Microsoft.NET.Build.Containers.Tasks.CreateNewImage.ToolExe.get -> string!
Microsoft.NET.Build.Containers.Tasks.CreateNewImage.ToolExe.set -> void
Microsoft.NET.Build.Containers.Tasks.CreateNewImage.ToolPath.get -> string!
Microsoft.NET.Build.Containers.Tasks.CreateNewImage.ToolPath.set -> void
Microsoft.NET.Build.Containers.Tasks.CreateNewImage.WorkingDirectory.get -> string!
Microsoft.NET.Build.Containers.Tasks.CreateNewImage.WorkingDirectory.set -> void
Microsoft.NET.Build.Containers.Tasks.CreateNewImage.GenerateLabels.get -> bool
Expand Down

This file was deleted.

Loading
Loading