dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
18.97k stars 4.03k forks source link

Csc.exe without -nologo requires Microsoft.CodeAnalysis.dll in BaseDirectory #12167

Open brthor opened 8 years ago

brthor commented 8 years ago

Version Used: csc.exe .NET Core

Steps to Reproduce:

Will Fill in Repro details.

Expected Behavior:

csc.exe runs

Actual Behavior:

Unhandled Exception: System.IO.FileNotFoundException: C:\Users\brthor\code\cli\artifacts\win10-x64\stage2\sdk\1.0.0-preview3-003156\Microsoft.CodeAnalysis.dll
     at System.Diagnostics.FileVersionInfo.GetVersionInfo(String fileName)
     at Roslyn.Utilities.PortableShim.Misc.GetFileVersion(String path)
     at Microsoft.CodeAnalysis.CommonCompiler.GetAssemblyFileVersion()
     at Microsoft.CodeAnalysis.CSharp.CSharpCompiler.PrintLogo(TextWriter consoleOutput)
     at Microsoft.CodeAnalysis.CommonCompiler.RunCore(TextWriter consoleOutput, ErrorLogger errorLogger, CancellationToken cancellationToken)
     at Microsoft.CodeAnalysis.CommonCompiler.Run(TextWriter consoleOutput, CancellationToken cancellationToken)
     at Microsoft.CodeAnalysis.CSharp.CommandLine.Csc.<>c__DisplayClass1_0.<Run>b__0(TextWriter tw)
     at Microsoft.CodeAnalysis.CommandLine.ConsoleUtil.RunWithUtf8Output[T](Func`2 func)
     at Microsoft.CodeAnalysis.CommandLine.ConsoleUtil.RunWithUtf8Output[T](Boolean utf8Output, TextWriter textWriter, Func`2 func)
     at Microsoft.CodeAnalysis.CSharp.CommandLine.Csc.Run(String[] args, BuildPaths buildPaths, TextWriter textWriter, IAnalyzerAssemblyLoader analyzerLoader)
     at Microsoft.CodeAnalysis.CommandLine.CoreClrBuildClient.RunLocalCompilation(String[] arguments, BuildPaths buildPaths, TextWriter textWriter)
     at Microsoft.CodeAnalysis.CommandLine.BuildClient.RunCompilation(IEnumerable`1 originalArguments, BuildPaths buildPaths, TextWriter textWriter)
     at Microsoft.CodeAnalysis.CommandLine.CoreClrBuildClient.Run(IEnumerable`1 arguments, RequestLanguage language, CompileFunc compileFunc)
     at Microsoft.CodeAnalysis.CSharp.CommandLine.Program.Main(String[] args)
gafter commented 8 years ago

Will Fill in Repro details.

Will pend this bug until you do.

eerhardt commented 8 years ago

Repro steps:

git clone https://github.com/dotnet/cli.git git checkout origin/feature/msbuild

// install the CLI $RepoRoot\scripts\obtain\dotnet-install.ps1 -Channel "feature-msbuild" -InstallDir "$RepoRoot\.dotnet_stage0"

// edit the test project under $RepoRoot\TestAssets\TestProjects\MSBuildTestApp\MSBuildTestApp.csproj by removing this line: https://github.com/dotnet/cli/blob/feature/msbuild/TestAssets/TestProjects/MSBuildTestApp/MSBuildTestApp.csproj#L19

// run the build $RepoRoot\.dotnet_stage0\dotnet.exe build3 $RepoRoot\TestAssets\TestProjects\MSBuildTestApp\MSBuildTestApp.csproj

Expected results

build passes

Actual results

CoreCompile:
  C:\LinuxShare\cli\.dotnet_stage0\dotnet.exe C:\LinuxShare\cli\.dotnet_stage0\sdk\1.0.0-feature-msbuild-003215\csc.exe /noconfig /nostdlib+ /platform:x64 /debug- /out:obj\x64\Debug\MSBuildTestApp.exe /target:exe /utf8output Program.cs "C:\Users\eerhardt\AppData\Local\Temp\NETCoreApp,Version=v1.0.AssemblyAttributes.cs"
  Using shared compilation with compiler from directory: C:\LinuxShare\cli\.dotnet_stage0
  Shared compilation failed; falling back to tool: C:\LinuxShare\cli\.dotnet_stage0\dotnet.exe

  Unhandled Exception: System.IO.FileNotFoundException: C:\LinuxShare\cli\.dotnet_stage0\sdk\1.0.0-feature-msbuild-003215\Microsoft.CodeAnalysis.dll
     at System.Diagnostics.FileVersionInfo.GetVersionInfo(String fileName)
     at Roslyn.Utilities.PortableShim.Misc.GetFileVersion(String path)
     at Microsoft.CodeAnalysis.CommonCompiler.GetAssemblyFileVersion()
     at Microsoft.CodeAnalysis.CSharp.CSharpCompiler.PrintLogo(TextWriter consoleOutput)
     at Microsoft.CodeAnalysis.CommonCompiler.RunCore(TextWriter consoleOutput, ErrorLogger errorLogger, CancellationToken cancellationToken)
     at Microsoft.CodeAnalysis.CommonCompiler.Run(TextWriter consoleOutput, CancellationToken cancellationToken)
     at Microsoft.CodeAnalysis.CSharp.CommandLine.Csc.<>c__DisplayClass1_0.<Run>b__0(TextWriter tw)
     at Microsoft.CodeAnalysis.CommandLine.ConsoleUtil.RunWithUtf8Output[T](Func`2 func)
     at Microsoft.CodeAnalysis.CommandLine.ConsoleUtil.RunWithUtf8Output[T](Boolean utf8Output, TextWriter textWriter, Func`2 func)
     at Microsoft.CodeAnalysis.CSharp.CommandLine.Csc.Run(String[] args, BuildPaths buildPaths, TextWriter textWriter, IAnalyzerAssemblyLoader analyzerLoader)
     at Microsoft.CodeAnalysis.CommandLine.CoreClrBuildClient.RunLocalCompilation(String[] arguments, BuildPaths buildPaths, TextWriter textWriter)
     at Microsoft.CodeAnalysis.CommandLine.BuildClient.RunCompilation(IEnumerable`1 originalArguments, BuildPaths buildPaths, TextWriter textWriter)
     at Microsoft.CodeAnalysis.CommandLine.CoreClrBuildClient.Run(IEnumerable`1 arguments, RequestLanguage language, CompileFunc compileFunc)
     at Microsoft.CodeAnalysis.CSharp.CommandLine.Program.Main(String[] args)
C:\LinuxShare\cli\.dotnet_stage0\sdk\1.0.0-feature-msbuild-003215\Microsoft.CSharp.Core.targets(67,5): error MSB6006: "C:\LinuxShare\cli\.dotnet_stage0\dotnet.exe" exited with code -532462766. [C:\LinuxShare\cli\TestAssets\TestProjects\MSBuildTestApp\MSBuildTestApp.csproj]
eerhardt commented 6 years ago

This appears to be fixed. I tried compiling a project that looks like

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <NoLogo>false</NoLogo>
  </PropertyGroup>

And it compiled just fine. This bug can be closed. I would close it, but I don't have permission.

We should also remove this comment from the dotnet/sdk repo:

https://github.com/dotnet/sdk/blob/35471d2fa7d6ce4a94035f08c5661ea722299a08/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.props#L123-L124

UPDATE: PR to remove above comment: https://github.com/dotnet/sdk/pull/1732