-
Notifications
You must be signed in to change notification settings - Fork 391
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
New .csproj cannot reference a traditional .csproj #1730
Comments
Updated repro steps. This bug only occurs after the initial package restore. |
I found a workaround: every new .csproj project must directly reference every transitively-referenced project.json project to avoid this bug. That's better than not being able to move forward but it's a lot of noise that does not truly represent necessary references. |
@jnm2 Package References will work in your winforms projects even though they are not yet on CPS. I would recommend moving away from project.json entirely and using package references for the projects that need to reference nuget packages. |
@jmarolf For some project.json projects that will work. For a number of them though, using a package reference instead of a project reference is quite awkward. I frequently need to step into and edit code in some of these projects. When I say frequently, I mean it'll be beyond aggravating to be working with binaries instead of a project. |
@jnm2 can you give an example? Every project.json idiom should have a matching concept in package reference. |
@jmarolf Not when you're using project.json simply as a necessary replacement for packages.config, if I understand you. @onovotny told me to start using project.json for all traditional .NET Framework .csprojs instead of packages.config when I was having issues with the new Humanizer packages. (He later wrote a guide: https://oren.codes/2016/02/08/project-json-all-the-things/) These project.json files do not create packages. They only hold public NuGet package references. A typical example: {
"dependencies": {
"Humanizer.Core": "2.1.0"
},
"frameworks": {
"net462": {}
},
"runtimes": {
"win": {}
}
} Using project.json over packages.config solved some big issues for us, especially related to source control. |
@jnm2 right, so delete the <ItemGroup>
<PackageReference Include="Humanizer.Core" Version="2.1.0" />
</ItemGroup> This is equivalent to your |
@jnm2 All project types can use |
You don't need to use the CPS projects to use |
That's awesome! VS2017-only is not a problem, but I didn't know I could do that. Is there a document detailing which CPS .csproj features can be used in traditional .csprojs with VS2017? |
All |
The next thing that comes to mind is... can VS2017 handle globbing in legacy projects just like it does in CPS projects? Besides PackageReference and globbing, what else can I use in the legacy projects? |
MSBuild can always handle globs...but VS will mess them up if you edit the project file :) |
@onovotny So PackageReference is the only new thing that came to legacy projects in VS2017? |
pretty much |
@emgarten Is this a NuGet issue? I also tried opting the GUI projects in the repro into
|
@dsplaisted did you delete the old |
Yes |
@dsplaisted the error you pasted is due to NuGet/Home#4532 it happens when a legacy csproj with PackageReference references another legacy csproj. |
I'm positive it was working before, but now it's saying:
None of the three libraries involved have a project.json. |
@dsplaisted @jnm2 This sounds like a nuget bug if you do not have and project.json or project.lock.json files on your system |
ProjectReferencesCreatingPackages errorThis error happens with legacy csproj + PackageReference due to NuGet/Home#4532 You will hit this issue if you restore from the command line. If you restore from Visual Studio the issue will not come up, so that may explain why you are hitting it intermittently. Invalid Line 1 error
Is caused by not having a direct reference to a transitive project. You can fix it by referencing all projects directly. For example with these projects: SuggestionsUsing NETCore SDK projects with Legacy csproj + project.json works great as long as you work around dotnet/sdk#922 We are currently using this for the NuGet repository. Legacy csproj + PackageReference shouldn't be used yet, it will be fixed soon in the next update of Visual Studio 2017. |
Oh boy haha, so there's no workaround? I should roll back the upgrades? |
We are using Legacy + PackageRef with MSAL here: https://github.com/azureAD/microsoft-authentication-library-for-dotnet There are some workarounds needed, but it does work.... |
This gives me hope for our Winforms projects. I'm not sure I want to go there yet, though. |
@dsplaisted I put a workaround for the project.json issue based on code @bbowman wrote on this MyGet feed |
* clean up projects * updated gitignore * more clean up * cleaned up test project * remove UWP app from release build * updated projects * remove NSubstitute. * add xforms ref * rename sln folder to avoid conflict with proj name * Add workaround for dotnet/project-system#1730
At this point I am very confused. I stopped using PackageReference for legacy csproj and put back the project.json as instructed, and it built fine on the build server, but in Visual Studio on my dev machine and on the command line I'm getting the exact same error as when I was using PackageReference:
Help? |
Apparently I need to delete my |
Nitpick: I'd like |
@jnm2 What's the state of this thread? It appears that we've got bugs on the issues you raised in thread with exception to With regards to clean, feel free to open a bug over on github.com/microsoft/msbuild, but what your asking is quite difficult - it would require MSBuild to persist every single output ever produced from a tree. |
Yes, I was thinking because of that difficulty, perhaps it should be the SDK's responsibility to clean itself up rather than MSBuild's. I'm not sure where the issue belongs.
Waiting for a fix. Right now there is a workaround, which is for the new csprojs to directly reference every transitively referenced legacy csproj. That is a bit obnoxious. It's not clear to me if you're saying legacy + |
MSBuild would be the correct place to file this. Given we've got NuGet bugs tracking your issue, I'll close this out. |
I'm looping back here from NuGet/Home#4532 to confirm that the ideal workaround, replacing project.json with PackageReference in all types of csproj, is now possible. I confirmed that this is working in 15.1.26303.3. |
Unfortunately some project combinations are still affected, particularly when transitive references are involved - https://github.com/dotnet/cli/issues/6294 |
[I can't find instructions on which repo to post this in. I'm happy to move it if need be.]
https://github.com/jnm2/misc-codesamples/raw/master/Bug%20reports/.NET/MSBuild%20old%20csproj%20issue.zip
Repro
To see the problem, build the .sln in Visual Studio. It fails with no errors.
Or, run the following from the VS2017 developer command prompt:
The clean fails (as do subsequent cleans and builds) with errors similar to:
Dilemma
This is purely net462 stuff. .NET Core and .NET Standard are not in the picture here. This makes it difficult to search for help on this issue because .NET Core information is inapplicable. MSBuild 15 can build traditional .csproj + project.json just fine. And that's a very good thing.
The GUI projects can't migrate away from .csproj + project.json (NuGet v3) because CPS does not support them yet.
Moving back to packages.config (NuGet v2) is not an option for a plethora of reasons, not least of which is that our application depends on packages that require project.json or later.
The non-GUI test project should be free to move forward to CPS .csproj (NuGet v4). The reason I'm undertaking the migration now is that all the test projects fail to build under MSBuild 15. They contain boilerplate from the VS2015 template such as
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
which works fine with MSBuild 14 and fails with MSBuild 15. Our new build server purposely has only Visual Studio 2017 installed, not VS2015, but this forces me to change all the test projects to play well with MSBuild 15. Since I have to spend time learning how to clean them up, I intended to save time by making our planned move to CPS now.I have no idea what's going on. Please provide a workaround and a fix. I have been planning and anticipating for ages to be able to migrate our console, class library and test projects to the new .csproj. It solves a number of issues for us. Not being able to move forward at all is incredibly disappointing.
The text was updated successfully, but these errors were encountered: