dotnet build folder reports "Project file does not exist" on Azure
Steps to reproduce
When using a .xproj project, I try to run "dotnet build D:\path\to\folder". Or if I CD into the project and run "dotnet build ." It fails on Azure. But it works on my computer.
This is failing on Azure only. On Azure, I have to cd into the folder, then run exactly dotnet build
Expected behavior
Build properly
Actual behavior
MSBUILD : error MSB1009: Project file does not exist.
Environment data
dotnet --info output:
.NET Command Line Tools (1.0.0-preview3-004056)
Product Information: Version: 1.0.0-preview3-004056 Commit SHA-1 hash: ccc4968bc3
Runtime Environment: OS Name: Windows OS Version: 6.2.9200 OS Platform: Windows RID: win8-x86
However, forcing the version with global.json to the following otherwise it doesn't build...
"sdk": {
"version": "1.0.0-preview2.1-003155"
}
Azure web apps includes prevew2, preview2.1, and preview3. Without a global.json the project will default to preview3 [the latest] which won't work for a project.json-based app.
Does the global.json address the issue for you?
@piotrpMSFT The global.json does not fix the issue. I have put the global.json in the folder first and it still say MSBUILD : error MSB1009: Project file does not exist.
Without the global.json but by doing dotnet build, I can't build (I get a different error error: MSB4019: The imported project "D:\Program Files (x86)\dotnet\sdk\1.0.0-preview3-004056\Extensions\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Props" was not found. Confirm that the path in the
With the global.json AND with dotnet build, it builds.
OK, I have retried this and it seems to work. This is definitely a strange behavior
1. global.json not in the root, does not compile
/path/where/global.json
/path/ > dotnet build ".\where"
This will fail with MSBUILD : error MSB1009: Project file does not exist.
Switch: .\where
2. global.json in the root
/path/global.json
/path/ > dotnet build ".\where"
It builds.
If this is a normal behavior then I guess you can close.
Yes, I believe what it does is walk up from the current folder looking for global.json. So if it's in a subfolder, it doesn't find it, even if it's in the folder of the app you're asking it to build. Frankly, I think that's a bit broken, but that's the behavior of dotnet.exe.
@davidebbo is right on. The issue here is that dotnet.exe doesn't know anything about build parameters and it selects a CLI version before delegating to build. By the time build figures out it has a project path it already is too late to select a different CLI. We could make different decisions, but this would kill the CLI's ability to be extensible since the root dotnet.exe would need to understand the invocation semantics of every extensibility command. We went with this direction because workaround by changing pwd is much easier than workaround by making a PR to the .net host cpp files and wait for CLI to re-ship...
@piotrpMSFT Since you are here to talk about this version, I have been searching on how to not use this global.json and use the --fx-version? This simply doesn't work... Is --fx-version supposed to work like that?
On Azure with no global.json
> dotnet
Version : 1.1.0-preview1-001100-00
...
--fx-version <version> Version of the installed Shared Framework to use to run the application.
...
> dotnet --info
Version: 1.0.0-preview3-004056
> dotnet --fx-version "1.0.0-preview2.1-003155" --info
Unknown option: --fx-version
Confusing much?
@schellap you should comment here as well
That is pretty frustrating. We need to do a better job of disambiguating fx version [runtime] from tools version [sdk]. What you are expecting from the last command, I suspect, is something I'd type as dotnet --sdk-version "1.0.0-preview2.1-003155" --info. However, due to a couple of behaviors what is happening is that the host ignores --fx-version because it goes into sdk mode and then the SDK fails to deal with --fx-version.
@schellap, can we do something in the host to make this simpler? some thoughts:
- add
--sdk-version - should the host honor
--fx-versionwhen in SDK mode? I think this could be nice in some scenarios - I think the host should have uniform handling of its options, and not pass them on to e.g. SDK in some cases
Thoughts?
add --sdk-version
Why is global.json within the project root not sufficient? I just wanted to understand why, before we add --sdk-version.
should the host honor --fx-version when in SDK mode? I think this could be nice in some scenarios
Is it just for testing? Then you can simply use: dotnet --fx-version "1.2.0" sdk/1.2.0/dotnet.dll --info at the expense of UX.
I think the host should have uniform handling of its options, and not pass them on to e.g. SDK in some cases
I think the help message states the --fx-version Version of the installed Shared Framework to use to run the application. It was never intended for the SDK.
Cc @gkhanna79
Picking a tool based on having a global.json in the root is not obvious. If you were to run dotnet.exe from a path I don't have access to drop any files, then we would never be able to choose the SDK version.
Also, the fact that Azure updates with new "previews" and in turn changes the behavior of the dotnet command makes me cringe... Especially the fact that it's not backward compatible. Now you will tell me "if I had put a global.json in the first place, it would not be a problem." But it's all these little things I have to do to make my site work that hinder my development/deployment.
In the output I pasted below, why dotnet and dotnet --info gives different version ? If they are different version (tool, sdk, framework?) maybe a description of what version is showing would help.
Like most of the tools we build as engineer, I believe we forget how other people are intending to use them.
@jsgoupil, I agree it is convenient to use a --sdk-version. I had been under the impression that the tooling always placed the global.json file. We can take care of this in dotnet.exe
@blackdwarf the version messaging is confusing, could you give this some thought so it would be less confusing? The problem is: dotnet.exe prints a version, dotnet.exe --version prints one version when SDK is present and another when it is absent.
I am actually actively working on proposing a fix for the version issues.
@schellap can you link the issue tracking this?
I agree it is convenient to use a --sdk-version. I had been under the impression that the tooling always placed the global.json file. We can take care of this in dotnet.exe
@blackdwarf any pointers to a work-in-progress?
@piotrpMSFT not yet, should be this week I hope.
ping @schellap
@piotrpMSFT filed https://github.com/dotnet/core-setup/issues/753 targeting for 1.2.0
Thanks @schellap. Closing in favor of dotnet/core-setup#753