Skip to content

Skip MSBuild and call only CSC for simple file-based apps #49528

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Jul 25, 2025
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
39a7d9e
Skip MSBuild and call only CSC for simple file-based apps
jjonescz Jun 23, 2025
ca2cb78
Fix tests
jjonescz Jun 23, 2025
e1ce450
Ignore newlines in generated files
jjonescz Jun 23, 2025
fa6a948
Avoid losing info through Zip
jjonescz Jun 23, 2025
ff90cf7
Ignore preferreduilang
jjonescz Jun 23, 2025
8b879a5
Resolve temp dir symlink so tests work on macOS
jjonescz Jun 23, 2025
436f51d
Avoid harcoding 10.0 in more places
jjonescz Jun 25, 2025
f780262
Extract TargetFrameworkVersion from Product
jjonescz Jun 26, 2025
d40f761
Merge branch 'main' into sprint-perf-2
jjonescz Jun 26, 2025
d8ada3d
Always copy NuGet.config to the test dir
jjonescz Jun 26, 2025
3734f09
Update CSC args
jjonescz Jun 26, 2025
334b618
Improve test error message
jjonescz Jun 26, 2025
595bbc3
Create test directory before copying a file to it
jjonescz Jun 26, 2025
36ff99e
Merge branch 'main' into sprint-perf-2
jjonescz Jul 1, 2025
e793756
Check implicit build files in tests
jjonescz Jul 2, 2025
ee62d93
Merge branch 'main' into sprint-perf-2
jjonescz Jul 2, 2025
ccd2294
Improve readability and tests
jjonescz Jul 3, 2025
7c58d43
Fixup DOTNET_ROOT test
jjonescz Jul 3, 2025
3649452
Merge branch 'main' into sprint-perf-2
jjonescz Jul 7, 2025
bb2ff7d
Improve code
jjonescz Jul 7, 2025
b6a7846
Avoid fallback when compiler hash doesn't match
jjonescz Jul 8, 2025
fa53861
Make error red instead of yellow
jjonescz Jul 8, 2025
ec9d3cd
Use macOS code sign in app host
jjonescz Jul 15, 2025
ae1e9c5
Merge branch 'main' into sprint-perf-2
jjonescz Jul 25, 2025
fcb0ba0
Use official BuildClient package version
jjonescz Jul 9, 2025
5ad89c0
Fixup merge
jjonescz Jul 25, 2025
c39b40f
Update runtime config baseline
jjonescz Jul 25, 2025
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
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<PackageVersion Include="Microsoft.Build.NuGetSdkResolver" Version="$(MicrosoftBuildNuGetSdkResolverPackageVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis" Version="$(MicrosoftCodeAnalysisPackageVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzer.Testing" Version="$(MicrosoftCodeAnalysisAnalyzerTestingVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.BuildClient" Version="5.0.0-1.25317.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="$(MicrosoftCodeAnalysisCSharpPackageVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="$(MicrosoftCodeAnalysisPackageVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Features" Version="$(MicrosoftCodeAnalysisCSharpPackageVersion)" />
Expand Down
1 change: 1 addition & 0 deletions NuGet.config
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<add key="richnav" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/vs-buildservices/nuget/v3/index.json" />
<!-- mstest dependencies -->
<add key="test-tools" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/test-tools/nuget/v3/index.json" />
<add key="temporary" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/general-testing/nuget/v3/index.json" />
</packageSources>
<disabledPackageSources>
<clear />
Expand Down
4 changes: 2 additions & 2 deletions src/Cli/Microsoft.DotNet.Cli.Utils/ArgumentEscaper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ private static IEnumerable<string> EscapeArgArrayForCmd(IEnumerable<string> argu
return escapedArgs;
}

public static string EscapeSingleArg(string arg)
public static string EscapeSingleArg(string arg, Func<string, bool>? additionalShouldSurroundWithQuotes = null)
{
var sb = new StringBuilder();

var length = arg.Length;
var needsQuotes = length == 0 || ShouldSurroundWithQuotes(arg);
var needsQuotes = length == 0 || ShouldSurroundWithQuotes(arg) || additionalShouldSurroundWithQuotes?.Invoke(arg) == true;
var isQuoted = needsQuotes || IsSurroundedWithQuotes(arg);

if (needsQuotes) sb.Append("\"");
Expand Down
22 changes: 18 additions & 4 deletions src/Cli/Microsoft.DotNet.Cli.Utils/Product.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,32 @@

namespace Microsoft.DotNet.Cli.Utils;

public class Product
public static class Product
{
public static string LongName => LocalizableStrings.DotNetSdkInfo;
public static readonly string Version = GetProductVersion();
public static readonly string Version;
public static readonly string TargetFrameworkVersion;

private static string GetProductVersion()
static Product()
{
DotnetVersionFile versionFile = DotnetFiles.VersionFileObject;
return versionFile.BuildNumber ??
Version = versionFile.BuildNumber ??
System.Diagnostics.FileVersionInfo.GetVersionInfo(
typeof(Product).GetTypeInfo().Assembly.Location)
.ProductVersion ??
string.Empty;

int firstDotIndex = Version.IndexOf('.');
if (firstDotIndex >= 0)
{
int secondDotIndex = Version.IndexOf('.', firstDotIndex + 1);
TargetFrameworkVersion = secondDotIndex >= 0
? Version.Substring(0, secondDotIndex)
: Version;
}
else
{
TargetFrameworkVersion = string.Empty;
}
}
}
6 changes: 5 additions & 1 deletion src/Cli/dotnet/Commands/CliCommandStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1539,9 +1539,13 @@ Tool '{1}' (version '{2}') was successfully installed. Entry is added to the man
<comment>{0} is an option name like '--no-build'.</comment>
</data>
<data name="NoBinaryLogBecauseUpToDate" xml:space="preserve">
<value>Warning: Binary log option was specified but build will be skipped because output is up to date, specify '--no-cache' to force build.</value>
<value>Warning: Binary log option was specified but build will be skipped because output is up to date. Specify '--no-cache' to force build.</value>
<comment>{Locked="--no-cache"}</comment>
</data>
<data name="NoBinaryLogBecauseRunningJustCsc" xml:space="preserve">
<value>Warning: Binary log option was specified but MSBuild will be skipped because running just csc is enough. Specify '--no-cache' to force full build.</value>
<comment>{Locked="--no-cache"}{Locked="MSBuild"}{Locked="csc"}</comment>
</data>
<data name="PublishAppDescription" xml:space="preserve">
<value>Publisher for the .NET Platform</value>
</data>
Expand Down
236 changes: 236 additions & 0 deletions src/Cli/dotnet/Commands/Run/CSharpCompilerCommand.Generated.cs

Large diffs are not rendered by default.

Loading
Loading