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

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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" />
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 This should go away before the PR is merged. I'm using this to get a test build of the BuildClient package before dotnet/roslyn#78986 is merged and we have an official build.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The package still didn't make it to dotnet/dotnet (and then to dotnet/sdk), currently waiting for dotnet/dotnet#1428

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost here, now waiting for #49740.

</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