Skip to content
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
946f90f
Allow MSBuildWorkspace to open file-based apps
jjonescz Jun 15, 2026
a0e4f7a
Add RemoteProjectInstance
jjonescz Jun 15, 2026
715a38f
Support `#:ref`s
jjonescz Jun 17, 2026
c850439
Merge branch 'main' into 78887-sprint-MSBuildWorkspace
jjonescz Jun 17, 2026
8a8efd0
Fixup use of ImmutableArray
jjonescz Jun 17, 2026
daf0e3a
Update to fix a leak
jjonescz Jun 17, 2026
70c8202
Remove unnecessary items
jjonescz Jun 17, 2026
ad8d824
Use VirtualProjectBuilder in FileBasedProgramsProjectSystem
jjonescz Jun 17, 2026
4f7e092
Test `#:ref` in LSP
jjonescz Jun 17, 2026
9d7ceee
Fixup tfm condition
jjonescz Jun 18, 2026
fb1d7eb
Merge branch 'main' into 78887-sprint-MSBuildWorkspace
jjonescz Jun 24, 2026
9fc0b90
Improve tests
jjonescz Jun 24, 2026
b66509c
Fixup net472
jjonescz Jun 24, 2026
6d97213
Improve global.json in tests
jjonescz Jun 24, 2026
52f1c2e
Test diagnostics
jjonescz Jun 25, 2026
b0cfe02
Remove CSharp dependency
jjonescz Jun 25, 2026
c4224f3
Move the whole builder to the service
jjonescz Jun 26, 2026
9a2c671
Improve code ordering
jjonescz Jun 26, 2026
a8cd5ba
Promote to workspace service
jjonescz Jun 26, 2026
95f50a3
Implement more BuildService APIs
jjonescz Jun 26, 2026
dba38e8
Improve BuildService implementation
jjonescz Jun 26, 2026
19a524a
Remove run-api usage
jjonescz Jun 26, 2026
3da4bd8
Extract TFM
jjonescz Jun 26, 2026
b62c59c
Share global build properties
jjonescz Jun 26, 2026
c31639f
Bump SDK to 10.0.301
jjonescz Jun 26, 2026
4b3e00d
Remove custom `global.json`s from tests
jjonescz Jun 26, 2026
a7b8321
Merge branch 'main' into 78887-sprint-MSBuildWorkspace
jjonescz Jun 26, 2026
7a3b860
Fix SourceRoot test
tmat Jun 24, 2026
f9d95e8
Remove unnecessary `using`
jjonescz Jun 29, 2026
1a104e8
Support extensionless file-based apps
jjonescz Jun 29, 2026
68bd559
Remove copied virtual project helpers
jjonescz Jun 29, 2026
4900670
Disable MSBuild server temporarily
jjonescz Jun 29, 2026
57ca53e
Fixup implementation of GetDiscoveryCacheRootDirectory
jjonescz Jun 29, 2026
1ad218f
Ensure fuzz repro is up-to-date
jjonescz Jun 29, 2026
06b57f1
Move the source package to Workspaces layer
jjonescz Jun 29, 2026
8cb6ea2
Prefer NetCore for file-based apps
jjonescz Jun 29, 2026
97a1252
Propagate cancellation token
jjonescz Jun 30, 2026
87968dd
Use `GetAwaiter().GetResult()`
jjonescz Jun 30, 2026
b5ca6df
Avoid loading non-existent DLLs in a test
jjonescz Jun 30, 2026
27c8141
Improve assert in a test
jjonescz Jun 30, 2026
8fef535
Merge branch 'main' into 78887-sprint-MSBuildWorkspace
jjonescz Jul 1, 2026
f04f656
Use physical file path in project map
jjonescz Jul 1, 2026
5c8f512
Simplify physical/virtual path split
jjonescz Jul 1, 2026
18522a2
Pass options to XmlReader
jjonescz Jul 1, 2026
aee4b35
Merge branch 'main' into 78887-sprint-MSBuildWorkspace
jjonescz Jul 21, 2026
f084b1f
Dispose remote project instances
jjonescz Jul 21, 2026
1fc2f1d
Use BundledNETCoreAppTargetFrameworkVersion
jjonescz Jul 21, 2026
84abddb
Share DeferDeleteCacheDirectory call
jjonescz Jul 21, 2026
06488a7
Improve how default TFM is specified
jjonescz Jul 22, 2026
be34fb2
Improve code
jjonescz Jul 22, 2026
b27925e
Avoid hang in self-referencing test
jjonescz Jul 22, 2026
3ade14a
Improve compilation references in a test
jjonescz Jul 22, 2026
75a1f82
Move ProjectRootElement cache outside VirtualProjectBuilder
jjonescz Jul 22, 2026
ae74a50
Handle global properties
jjonescz Jul 22, 2026
29f58c4
Add comments
jjonescz Jul 27, 2026
74f01cf
Ensure MSBuildUtilities are still included
jjonescz Jul 27, 2026
51442eb
Get all item metadata values at once
jjonescz Jul 27, 2026
2d3aeaf
Check disposal like the other entrypoints
jjonescz Jul 27, 2026
54cf60f
Make IBuildService async
jjonescz Jul 27, 2026
6bc96ff
Clarify RPC API
jjonescz Jul 27, 2026
9943ae8
Add `ConfigureAwait(false)`
jjonescz Jul 27, 2026
6dc5b9e
Narrow data guard hold
jjonescz Jul 27, 2026
371a034
Test AssociateFileExtensionWithLanguage
jjonescz Jul 29, 2026
c9b40e0
Document file-based app support
jjonescz Jul 29, 2026
d7cfdbb
Update to a merged commit hash
jjonescz Jul 29, 2026
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
60 changes: 54 additions & 6 deletions eng/ensure-sources-synced.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

using System.Net.Http.Headers;
using System.Text.Json;
using System.Text.RegularExpressions;

// Verifies or updates the shared source files under `src/Features/CSharp/Portable/SyncedSource/FileBasedPrograms`
// using files from dotnet/sdk at the commit specified in `src/Features/CSharp/Portable/SyncedSource/commitid.txt`.
Expand Down Expand Up @@ -76,10 +77,10 @@ static async Task MainAsync(string[] args)
.ToHashSet(StringComparer.OrdinalIgnoreCase);

var mismatches = new List<string>();
foreach (var sourceFile in sourcePackageFiles)

void ProcessFile(string relativePath, string sourceContent)
{
var localFile = Path.Combine(localSourceDir, sourceFile.RelativePath.Replace('/', Path.DirectorySeparatorChar));
var sourceContent = await GetGitHubStringAsync(httpClient, sourceFile.DownloadUrl).ConfigureAwait(false);
var localFile = Path.Combine(localSourceDir, relativePath.Replace('/', Path.DirectorySeparatorChar));

if (!File.Exists(localFile))
{
Expand All @@ -91,8 +92,8 @@ static async Task MainAsync(string[] args)
File.WriteAllText(localFile, sourceContent);
}

mismatches.Add($"Added missing file: {sourceFile.RelativePath}");
continue;
mismatches.Add($"Added missing file: {relativePath}");
return;
}

var localContent = File.ReadAllText(localFile);
Expand All @@ -101,10 +102,23 @@ static async Task MainAsync(string[] args)
if (mode == SyncMode.Update)
File.WriteAllText(localFile, sourceContent);

mismatches.Add($"Updated file: {sourceFile.RelativePath}");
mismatches.Add($"Updated file: {relativePath}");
}
}

foreach (var sourceFile in sourcePackageFiles)
{
var sourceContent = await GetGitHubStringAsync(httpClient, sourceFile.DownloadUrl).ConfigureAwait(false);
ProcessFile(sourceFile.RelativePath, sourceContent);
}

// Generate a constants file from the SDK's ToolsetInfo.cs so the synced source can reference the
// current target framework instead of hardcoding it.
Comment thread
jasonmalinowski marked this conversation as resolved.
Resolved
const string generatedConstantsRelativePath = "FileBasedAppConstants.cs";
var generatedConstantsContent = await GenerateConstantsFileAsync(httpClient, sdkCommit).ConfigureAwait(false);
expectedRelativePaths.Add(generatedConstantsRelativePath);
ProcessFile(generatedConstantsRelativePath, generatedConstantsContent);

if (Directory.Exists(localSourceDir))
{
var localMirrorFiles = Directory.GetFiles(localSourceDir, "*", SearchOption.AllDirectories)
Expand Down Expand Up @@ -225,6 +239,40 @@ static async Task<List<SyncedFile>> GetDirectoryFilesAsync(
return files;
}

static async Task<string> GenerateConstantsFileAsync(HttpClient client, string commit)
{
var url = $"https://raw.githubusercontent.com/dotnet/sdk/{commit}/test/Microsoft.NET.TestFramework/ToolsetInfo.cs";
Comment thread
jasonmalinowski marked this conversation as resolved.
Resolved
var content = await GetGitHubStringAsync(client, url).ConfigureAwait(false);

var match = Regex.Match(content, """CurrentTargetFramework\s*=\s*"(?<tfm>[^"]+)"\s*;""");
if (!match.Success)
throw new InvalidOperationException($"Could not find 'CurrentTargetFramework' constant in '{url}'.");

var currentTargetFramework = match.Groups["tfm"].Value;

return $$"""
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

// <auto-generated>
// Generated by eng/ensure-sources-synced.cs from the 'CurrentTargetFramework' constant in
// test/Microsoft.NET.TestFramework/ToolsetInfo.cs in dotnet/sdk. Do not edit manually.
// </auto-generated>

namespace Microsoft.DotNet.FileBasedPrograms;

internal static class FileBasedAppConstants
{
/// <summary>
/// The current target framework for file-based apps, sourced from
/// <c>ToolsetInfo.CurrentTargetFramework</c> in dotnet/sdk.
/// </summary>
public const string CurrentTargetFramework = "{{currentTargetFramework}}";
}

""";
}

static bool IsRateLimitResponse(System.Net.HttpStatusCode statusCode, HttpResponseHeaders headers, string responseBody)
{
if (statusCode == System.Net.HttpStatusCode.TooManyRequests)
Expand Down
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"sdk": {
"version": "10.0.109",
"version": "10.0.301",
"allowPrerelease": false,
"rollForward": "patch"
},
"tools": {
"dotnet": "10.0.109",
"dotnet": "10.0.301",
"vs": {
"version": "17.14.0"
},
Expand Down
9 changes: 6 additions & 3 deletions src/Compilers/Core/MSBuildTaskTests/DotNetSdkTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ public void TestSourceLink()
[ConditionalTheory(typeof(DotNetSdkAvailable))]
[CombinatorialData]
[WorkItem(43476, "https://github.com/dotnet/roslyn/issues/43476")]
[WorkItem(82112, "https://github.com/dotnet/roslyn/issues/82112")]
public void InitializeSourceRootMappedPathsReturnsSourceMap(bool deterministicSourcePaths)
{
ProjectDir.CreateFile("Project2.csproj").WriteAllText($@"
Expand Down Expand Up @@ -344,9 +345,11 @@ public void InitializeSourceRootMappedPathsReturnsSourceMap(bool deterministicSo
},
expectedResults: new[]
{
$"X{Path.DirectorySeparatorChar}",
$"Y{Path.DirectorySeparatorChar}",
$"Z{Path.DirectorySeparatorChar}",
// SourceRoot items are canonicalized to absolute paths by the MapSourceRoots task
// invoked from the InitializeSourceRootMappedPaths target.
Path.GetFullPath(Path.Combine(ProjectDir.Path, "X")) + Path.DirectorySeparatorChar,
Path.GetFullPath(Path.Combine(ProjectDir.Path, "Y")) + Path.DirectorySeparatorChar,
Path.GetFullPath(Path.Combine(ProjectDir.Path, "Z")) + Path.DirectorySeparatorChar,
Comment thread
jjonescz marked this conversation as resolved.
Resolved
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.Composition;
using System.IO;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.DotNet.FileBasedPrograms;

namespace Microsoft.CodeAnalysis.FileBasedPrograms;

[Export(typeof(IFileBasedProgramService)), Shared]
[ExportWorkspaceService(typeof(IFileBasedProgramService))]
[method: ImportingConstructor]
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed class FileBasedProgramService() : IFileBasedProgramService
{
public IDictionary<string, string> GetGlobalBuildProperties()
{
var result = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
foreach (var kvp in VirtualProjectBuilder.GetGlobalBuildProperties())
{
result.Add(kvp.Key, kvp.Value);
}
return result;
}

public IProjectRootElement LoadFileBasedAppProject(
IBuildService buildService,
IProjectCollection projectCollection,
string entryPointFilePath,
Action<string> reportError)
{
var entryPointFileFullPath = Path.GetFullPath(entryPointFilePath);
var virtualProjectBuilder = new VirtualProjectBuilder(buildService, entryPointFileFullPath, FileBasedAppConstants.CurrentTargetFramework);
virtualProjectBuilder.CreateProjectInstance(
projectCollection,
(text, path, textSpan, message, innerException) => reportError($"{new SourceFile(path, text).GetLocationString(textSpan)}: {message}"),
project: out _,
out var projectRootElement,
evaluatedDirectives: out _);
return projectRootElement;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<Compile Include="..\..\..\Compilers\CSharp\Portable\Syntax\LambdaUtilities.cs">
<Link>InternalUtilities\LambdaUtilities.cs</Link>
</Compile>
<Compile Remove="SyncedSource\FileBasedPrograms\IBuildService.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="CSharpFeaturesResources.resx" GenerateSource="true" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable enable
using System.Collections.Generic;

namespace Microsoft.DotNet.Utilities;

internal static class Extensions
{
#if !NET
public static HashSet<T> ToHashSet<T>(this IEnumerable<T> source, IEqualityComparer<T> comparer)
{
return new HashSet<T>(source, comparer);
}
#endif
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

// <auto-generated>
// Generated by eng/ensure-sources-synced.cs from the 'CurrentTargetFramework' constant in
// test/Microsoft.NET.TestFramework/ToolsetInfo.cs in dotnet/sdk. Do not edit manually.
// </auto-generated>

namespace Microsoft.DotNet.FileBasedPrograms;

internal static class FileBasedAppConstants
{
/// <summary>
/// The current target framework for file-based apps, sourced from
/// <c>ToolsetInfo.CurrentTargetFramework</c> in dotnet/sdk.
/// </summary>
public const string CurrentTargetFramework = "net10.0";
}
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,14 @@
<value>The '#:project' directive is invalid: {0}</value>
<comment>{0} is the inner error message.</comment>
</data>
<data name="InvalidRefDirective" xml:space="preserve">
<value>The '#:ref' directive is invalid: {0}</value>
<comment>{Locked="#:ref"}{0} is the inner error message.</comment>
</data>
<data name="CouldNotFindRefFile" xml:space="preserve">
<value>Could not find file '{0}'.</value>
<comment>{0} is the file path.</comment>
</data>
<data name="MissingDirectiveName" xml:space="preserve">
<value>Missing name of '{0}'.</value>
<comment>{0} is the directive name like 'package' or 'sdk'.</comment>
Expand All @@ -175,14 +183,25 @@
</data>
<data name="InvalidIncludeExcludeMappingEntry" xml:space="preserve">
<value>Each entry in 'FileBasedProgramsItemMapping' MSBuild property must have two parts separated by '='. The entry '{0}' is invalid.</value>
<comment>{Locked="FileBasedProgramsItemMapping"}{Locked="MSBuild"}{Locked="="}</comment>
<comment>{Locked="FileBasedProgramsItemMapping"}{Locked="MSBuild"}{Locked="'='"}</comment>
</data>
<data name="InvalidIncludeExcludeMappingExtension" xml:space="preserve">
<value>Each entry in 'FileBasedProgramsItemMapping' MSBuild property must map from a non-empty file extension starting with '.'. The extension '{0}' in entry '{1}' is invalid.</value>
<comment>{Locked="FileBasedProgramsItemMapping"}{Locked="MSBuild"}{Locked="."}</comment>
<comment>{Locked="FileBasedProgramsItemMapping"}{Locked="MSBuild"}{Locked="'.'"}</comment>
</data>
<data name="InvalidIncludeExcludeMappingItemType" xml:space="preserve">
<value>Each entry in 'FileBasedProgramsItemMapping' MSBuild property must map to a non-empty item type. The item type '{0}' in entry '{1}' is invalid.</value>
<comment>{Locked="FileBasedProgramsItemMapping"}{Locked="MSBuild"}</comment>
</data>
<data name="EmptyTempPath" xml:space="preserve">
<value>Unable to determine a temporary directory path. Consider configuring the TEMP environment variable on Windows or local app data folder on Unix.</value>
</data>
<data name="IncludedFileNotFound" xml:space="preserve">
<value>File included via #:include directive (or Compile item) not found: {0}</value>
<comment>{Locked="#:include"}{Locked="Compile"}. {0} is file path.</comment>
</data>
<data name="ExperimentalFeatureDisabled" xml:space="preserve">
<value>This is an experimental feature, set MSBuild property '{0}' to 'true' to enable it.</value>
<comment>{Locked="MSBuild"}{Locked="true"}. {0} is MSBuild property name.</comment>
</data>
</root>
Loading
Loading