try
try copied to clipboard
Try verify fails the second time with custom output paths
Describe the bug
From CMD or git for windows bash:
dotnet new -i Microsoft.DotNet.Try.ProjectTemplate.Tutorial
mkdir Try
cd Try
dotnet new trydotnet-tutorial
dotnet try verify # Successful
dotnet try verify # Fails
Errors on 2nd or more attempts:
(ins)$ dotnet try verify
C:\dev\unitsnet\Try2\Readme.md
------------------------------
Checking Markdown...
✓ Line 8: C:\dev\unitsnet\Try2\Program.cs (in project C:\dev\unitsnet\Try2\Try2.csproj)
Compiling samples for region "HelloWorld"
Build failed for project C:\dev\unitsnet\Try2\Try2.csproj
C:\dev\unitsnet\Try2\Program.cs(1,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
C:\dev\unitsnet\Try2\Program.cs(2,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
C:\dev\unitsnet\Try2\Program.cs(9,18): error CS0518: Predefined type 'System.Object' is not defined or imported
C:\dev\unitsnet\Try2\Program.cs(18,13): error CS0518: Predefined type 'System.String' is not defined or imported
C:\dev\unitsnet\Try2\Program.cs(19,13): error CS0518: Predefined type 'System.String' is not defined or imported
C:\dev\unitsnet\Try2\Program.cs(20,13): error CS0518: Predefined type 'System.String' is not defined or imported
C:\dev\unitsnet\Try2\Program.cs(21,13): error CS0518: Predefined type 'System.String' is not defined or imported
C:\dev\unitsnet\Try2\Program.cs(22,13): error CS0518: Predefined type 'System.String' is not defined or imported
C:\dev\unitsnet\Try2\Program.cs(17,16): error CS0518: Predefined type 'System.Int32' is not defined or imported
C:\dev\unitsnet\Try2\Program.cs(32,25): error CS0518: Predefined type 'System.Int32' is not defined or imported
C:\dev\unitsnet\Try2\Program.cs(40,25): error CS0518: Predefined type 'System.Int32' is not defined or imported
(1,1): error CS5001: Program does not contain a static 'Main' method suitable for an entry point
C:\dev\unitsnet\Try2\Program.cs(26,17): error CS0518: Predefined type 'System.String' is not defined or imported
C:\dev\unitsnet\Try2\Program.cs(26,33): error CS0518: Predefined type 'System.Object' is not defined or imported
C:\dev\unitsnet\Try2\Program.cs(27,17): error CS0518: Predefined type 'System.String' is not defined or imported
C:\dev\unitsnet\Try2\Program.cs(27,31): error CS0518: Predefined type 'System.Object' is not defined or imported
C:\dev\unitsnet\Try2\Program.cs(28,32): error CS0518: Predefined type 'System.Object' is not defined or imported
C:\dev\unitsnet\Try2\Program.cs(28,32): error CS0246: The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)
C:\dev\unitsnet\Try2\Program.cs(28,50): error CS0518: Predefined type 'System.String' is not defined or imported
C:\dev\unitsnet\Try2\Program.cs(35,1): error CS0518: Predefined type 'System.Object' is not defined or imported
C:\dev\unitsnet\Try2\Program.cs(35,1): error CS0103: The name 'Console' does not exist in the current context
C:\dev\unitsnet\Try2\Program.cs(35,19): error CS0518: Predefined type 'System.String' is not defined or imported
C:\dev\unitsnet\Try2\Program.cs(37,20): error CS0518: Predefined type 'System.Int32' is not defined or imported
C:\dev\unitsnet\Try2\Program.cs(43,13): error CS0518: Predefined type 'System.Object' is not defined or imported
C:\dev\unitsnet\Try2\Program.cs(43,13): error CS0103: The name 'Console' does not exist in the current context
C:\dev\unitsnet\Try2\Program.cs(43,31): error CS0518: Predefined type 'System.Object' is not defined or imported
C:\dev\unitsnet\Try2\Program.cs(43,31): error CS0103: The name 'System' does not exist in the current context
C:\dev\unitsnet\Try2\Program.cs(45,20): error CS0518: Predefined type 'System.Int32' is not defined or imported
C:\dev\unitsnet\Try2\Program.cs(9,18): error CS1729: 'object' does not contain a constructor that takes 0 arguments
dotnet try verify found 1 error(s)
Workaround
dotnet clean
dotnet try verify # Successful again!
I tried cloning the try-samples repo, but I cannot reproduce there. I have tried spotting the difference between my .csproj, Program.cs and markdown files and those at try-samples repo, but I can't find anything that stands out.
.NET info:
$ dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 3.1.101
Commit: b377529961
Runtime Environment:
OS Name: Windows
OS Version: 10.0.18363
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.1.101\
Host (useful for support):
Version: 3.1.1
Commit: a1388f194c
.NET Core SDKs installed:
1.1.14 [C:\Program Files\dotnet\sdk]
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.508 [C:\Program Files\dotnet\sdk]
2.1.509 [C:\Program Files\dotnet\sdk]
2.1.801 [C:\Program Files\dotnet\sdk]
2.1.802 [C:\Program Files\dotnet\sdk]
2.2.108 [C:\Program Files\dotnet\sdk]
2.2.401 [C:\Program Files\dotnet\sdk]
2.2.402 [C:\Program Files\dotnet\sdk]
3.0.103 [C:\Program Files\dotnet\sdk]
3.1.101 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 1.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 1.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Did this error occur while using dotnet try
or online?
- [x]
dotnet-try
- [ ] .NET Jupyter Notebook
- [ ] online
What kind of error was it?
- [ ] User Interface (UI): For example the output never displayed
- [ ] Service Error: For example "The service is temporarily unavailable. We are working on it"
- [x] Other:
dotnet-try
tool
Screenshots
If applicable, add screenshots to help explain your problem.
Please complete the following:
- OS
- [x] Windows 10
- [ ] macOS
- [ ] Linux (Please specify distro)
- [ ] iOS
- [ ] Android
- Browser
- [ ] Chrome
- [ ] Edge
- [ ] Safari
These issues seem related: https://github.com/dotnet/try/issues/181 https://github.com/dotnet/try/issues/191#issuecomment-492531292
Aha, typing this all out helped me figure it out.
I am trying this out inside my c:\dev\unitsnet
project.
In that project, there is a Directory.Build.props
file with
<!-- Avoid sharing obj folder with multiple .csproj files in same folder -->
<BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)obj/$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath>$(MSBuildThisFileDirectory)Artifacts/$(MSBuildProjectName)</OutputPath>
Workaround
Add these to my Try.csproj
to override the defaults back to normal output paths.
<OutputPath>bin</OutputPath>
<BaseIntermediateOutputPath>obj</BaseIntermediateOutputPath>
Any idea why this breaks the tool? Might be worth investigating.
The reason we added this config was that we at some point had multiple .csproj
files in the same folder, but we have since removed that so I can remove the BaseIntermediateOutputPath
in my props file and voila - I no longer need any of the lines in the workaround.
Turns out I had to add <OutputPath>bin/$(Configuration)</OutputPath>
to my Try.csproj
, as logs complained it could not find Try.dll
. Revised the title of this issue to reflect this.
I am no longer blocked, so you can close it for me, but keeping it open in case you want to look into the case of custom output paths not being supported.