DynamicsValue / fake-xrm-easy

FakeXrmEasy: The Test Automation Framework for the Power Platform / Dataverse
https://dynamicsvalue.github.io/fake-xrm-easy-docs/why/
Other
25 stars 12 forks source link

Build Issues: Assets file 'C:\DynamicsValue\fake-xrm-easy\src\FakeXrmEasy\obj\project.assets.json' doesn't have a target for 'net452'. #55

Open bwmodular opened 2 years ago

bwmodular commented 2 years ago

I'm trying to build the project(s) using the instructions in Readme.md. I have cloned all of the 2x-dev repos to a folder structure like this: image I have all of the prerequisites installed. When I run any of the build scripts (eg ./build.ps1 -targetFrameworks all) I get a slew of errors, but the first is this: _C:\Program Files\dotnet\sdk\6.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(267,5): error NETSDK1005: Assets file 'C:\DynamicsValue\fake-xrm-easy\src\FakeXrmEasy\obj\project.assets.json' doesn't have a target for 'net452'. Ensure that restore has run and that you have included 'net452' in the TargetFrameworks for your project. [C:\DynamicsValue\fake-xrm-easy\src\FakeXrmEasy\FakeXrmEasy.csproj]_

Not sure if I'm doing something wrong?

BetimBeja commented 2 years ago

Hi @bwmodular I think you need to build-push-local.ps1 -targetFrameworks all in the following order https://github.com/DynamicsValue/fake-xrm-easy#build-dependencies

jordimontana82 commented 2 years ago

It could be what Betim says, you need the projects in the order specified. If you try building just the fake-xrm-easy-abstractions repo first to try? @bwmodular ?

jordimontana82 commented 2 years ago

I'm assuming you also have the sdks for net 4.5.2 and 4.6.2 installed?

jordimontana82 commented 2 years ago

@bwmodular there is also the build-all.ps1 script which tries to build everything too, it might take quite some time, but it's a once off task, then we can push versions from each repo.

imagen

Please run another git-checkout.ps1 script to sync all branches in all repos to 2x-dev before running the build-all one.

That's something I added after the README.md ... too many commits!

bwmodular commented 2 years ago

Thanks both - running things in the right order is definitely helping - Sorry! Still getting some errors but I'll spend some more time seeing how much further I can get and report back.... I did try build-all.ps1 first but that really wasn't happy at all, so trying each project one by one now.....

bwmodular commented 2 years ago

Well, I tried, but still no luck getting anything built or pushed. This all makes me feel pretty dumb as I'm sure it must be something obvious.

Anyway, it's worth persevering because: a.) I want to be able to contribute to the project and b.) this needs to be made as easy and foolproof as possible - one of the great things about v1 was that you could just download and compile it and then you could see and hundreds of examples of how to write tests to test certain things, whereas now it seems like it might take tens of minutes just to get the point where everything is built. You don't want people giving up just because it's too complicated to get the project to build.

I tried doing build-all target-frameworks all - this is a mixed bag of failure and successes while the script runs but ultimately falls over with this error: FakeXrmEasy.Plugins.Performance\PipelineBenchmarks.cs(39,21): error CS0117: 'PluginStepDefinition' does not contain a definition for 'ImagesDefinitions'

So I then tried to break it down solution by solution.

Here are my results after running build-push-local.ps1 -targetFrameworks all in the order specified in the dependencies section. My forks were only created and cloned yesterday but I’ve made sure they are up to date with orig. Abstractions: Running gives me this smiley result:

image

but while the script is running there are lots of errors thrown up:

image

and

image

Trying to build the Abstractions solution in Visual Studio straight afterwards gives me loads of errors like this:

image

Core Again, seems like a happy ending: image

But lots of errors along the way:

image

And if I try and build in Visual Studio: image

Messages – Pretty much the same as Core Plugins – Lots of errors while the script runs and then a hard failure: C:\DynamicsValue\fake-xrm-easy-plugins\performance\FakeXrmEasy.Plugins.Performance\PipelineBenchmarks.cs(39,21): error CS0117: 'PluginStepDefinition' does not contain a definition for 'ImagesDefinitions' Code-Activities – The script runs without errors but I still can't build in Visual Studio afterwards Fake-xrm-easy – fails with the original error about not having a target for net452, along with lots of not surprising errors about missing dependencies. image

Bottom line is that I couldn't really get anything building and certainly not getting to the point where anything compiles in Visual Studio.

jordimontana82 commented 2 years ago

Hi Ben, Agree with all you said.

Maybe it could be that you pulled a version while I was in the middle of some changes in the package dependencies in the .csproj, cause I see a mixture of 2.2.0 and 2.1.1 in your logs when building the abstractions package.

If you do

pwsh ./git-pull.ps1

in the abstractions package and then build again to see abstractions package errors go away now?

jordimontana82 commented 2 years ago

@bwmodular I've raised another issue to improve the whole cloning, pulling , and building for the first time:

56

@BetimBeja

Any ideas welcome :)

bwmodular commented 2 years ago

If you do

pwsh ./git-pull.ps1

in the abstractions package and then build again to see abstractions package errors go away now?

@jordimontana82 Thanks for this. I think I'm all up to date: image and image

jordimontana82 commented 2 years ago

@bwmodular You can run git-pull.ps1 without params, and it'll pull all branches. It was a shortcut to be on latest of everything without doing it manually via git pull for each....

jordimontana82 commented 2 years ago

Does it build now? At least the abstractions one...

bwmodular commented 2 years ago

gitppull on fake-xrm-easy & fake-xrm-easy-abstractions shows I'm up to date: image build-push-local.ps1 -targetFrameworks all still producing lots of errors. I suspect that we're going to have to start going through the errors from the top and try and work out each one, but I don't want to take your time this week as you're preparing for Bizz. Maybe we can have a teams session after Bizz so you can see what's going on. This is the first error that gets thrown up: C:\Program Files\dotnet\sdk\6.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(267,5): error NETSDK1005: Assets file 'C:\DynamicsValue\fake-xrm-easy-abstractions\src\FakeXrmEasy.Abstractions\obj\project.assets.json' doesn't have a target for 'net462'. Ensure that restore has run and that you have included 'net462' in the TargetFrameworks for your project. [C:\DynamicsValue\fake-xrm-easy-abstractions\src\FakeXrmEasy.Abstractions\FakeXrmEasy.Abstractions.csproj] This comes after a succesful build and pack of FakeXrmEasy.Abstractions.v2016,so I think its FAKE_XRM_EASY_365 that's failing. All subsequent builds of the different Abstractions packages fail after this one.

jordimontana82 commented 2 years ago

+1 to Teams session

bwmodular commented 2 years ago

Thought I'd try a different approach. Abstractions should build on its own as it's at the top of the dependency hierarchy, yes?

I downloaded the current version of the Abstractions solution from orig: https://github.com/DynamicsValue/fake-xrm-easy-abstractions just using the Download Zip option from GitHub web. So I must have the latest version.

Opened in Visual Studio, tried to build. Get lots of these: image

Go to 'Manage NuGet Packages for Solution' and these are the only packages it thinks are installed: image

So not surprising it can't find Xrm or any of the other references. Tried it on two different machines with 4.5.2 and 4.62 intalled.

It must be something obvious, but can't work out what I'm missing.

jordimontana82 commented 2 years ago

Thought I'd try a different approach. Abstractions should build on its own as it's at the top of the dependency hierarchy, yes?

Yep

That's really weird, the restore should just work with build.ps1 -targetFrameworks all (there is a step that restores all packages there).

Not sure if related, but I didn't try to build the project with .net 6.0 yet, only with net core 3.1. I don't know if you could try, otherwise I'll try building it in .net60 when I have a chance.

bwmodular commented 2 years ago

Interestingly, the 462 build works OK, but the .netCore one doesn't. So this works fine: .\build.ps1 -targetFrameworks net462 But this .\build.ps1 -targetFrameworks netcoreapp3.1 does not, giving lots of: The type or namespace name 'EntityReference' could not be found type errors.

This would (kind of) explain why I can't build in Visual Studio. In Visual Studio, I can't actually change the TargetFramework, it's greyed out: image

.Net Core SDK 3.1 is definitely installed: image

jordimontana82 commented 2 years ago

HI Ben,

netcoreapp3.1 won't build in 2x- branches, you need to build it in 3x- ones. However ./build.ps1 -targetFrameworks all should work in all.

bwmodular commented 2 years ago

Yes of course - obvious really, sorry.

So, .\build.ps1 -targetFrameworks net462 works and .\build.ps1 -targetFrameworks all works but .\build-push-local.ps1 -targetFrameworks all fails with the missing references errors and Visual Studio won't build at all.

jordimontana82 commented 2 years ago

Ok, it seems this definitely needs a Teams call cause I ran all these scripts in both branches without issues myself at least :)

jordimontana82 commented 2 years ago

One last thing actually, if you manually delete de packages folder (where references are restored) and try again?

bwmodular commented 2 years ago

No luck deleting the packages folder - same issues. I'd have been surprised if it works as I've tried it on two different machines and both via cloned repo and direct download from GitHub into a different folder. In Visual Studio, Restore Nuget Packages says 'All Packages up to date' and the packages folder is full of folders including crm sdk assemblies, but in Visual Studio it looks like none of the NuGet packages are installed. All v odd....

jordimontana82 commented 2 years ago

What version of VS and Powershell are you using Ben?

bwmodular commented 2 years ago

I've tried it in VS 2019 and VS 2022. But Powershell 5.1 - Hmm - I'll try upgrading to v7. I assumed that my new win11 laptop would have latest PS but no. I'll upgrade and try again....

jordimontana82 commented 2 years ago

I'm using a Win10 and Ubuntu myselft, so didnt' try Win 11 to at least build this project...but good to know Win 11 comes with a fancy PS 5 by default!

bwmodular commented 2 years ago

Upgrading to PS 7 on my Win10 machine hasn't helped. I'm still getting lots of errors - mostly the old favourite: Assets file 'C:\DynamicsValue\fake-xrm-easy-abstractions\src\FakeXrmEasy.Abstractions\obj\project.assets.json' doesn't have a target for 'net462'. And (obviously) still no luck with Visual Studio. I doubt my Win11 machine will be any different but will report back if I'm proved wrong :-)

jordimontana82 commented 2 years ago

Are you running scripts as a local admin? Wondering about file permissions and so on....

bwmodular commented 2 years ago

Yes, you can't run most of these commands in PS without having first of all given PS permission to download files, etc, and I've also tried in ISE as Admin.

bwmodular commented 2 years ago

Well, I worked out why the abstractions project wouldn't build in Visual Studio at least. When you first open a project in VS it defaults the Solution Configuration to debug. image Changing it to one of the FakeXrmEasy configs causes it to download the appropriate libraries from NuGet. But you still see this error when you build: image But once you close and re-open the solution it builds ok!

Well, not every configuration does, but most do. If I switch to FAKE_XRM_EASY_365, I get this error: image and this: image and if I open FAKE_XRM_EASY_9 I get this: image

So, I can now get every version apart from 9 and 365 to build in VS. Still no luck with build.ps though, but I feel like I've made a small amount of progress today :-)

jordimontana82 commented 2 years ago

Ahhh ok. Yeah, if try closing & restarting VS after changing the configuration?

jordimontana82 commented 2 years ago

The project builds just fine via console, but VS seems to go mad with these conditional symbols in the .csproj...

bwmodular commented 2 years ago

If I amend this line in the two csproj files (src & test) in Abstractions, I can get all of the projects to build in VS: TargetFrameworks Condition="'$(Configuration)'=='FAKE_XRM_EASY_365'">net462;net452</TargetFrameworks to TargetFrameworks Condition="'$(Configuration)'=='FAKE_XRM_EASY_365'">net462</TargetFrameworks removing the reference to net452.

I don't know if this is something I can legitimately do, but it at least allows me to build.

One really annoying thing in VS is that you can't even see which configuration you are currently using! image Very annoying when you've having to switch between them to test different versions.

jordimontana82 commented 11 months ago

@bwmodular There have a few updates to the build and clean scripts. Do you still have these issues by any chance (i.e. using Rider lately and the switching of configurations is seamless....)

@temmyraharjo Did you face the same issues as Ben with latest version?

temmyraharjo commented 11 months ago

Hi @jordimontana82, Yes, I getting the same error using VS 2022. But when using Rider (sorry Jordi, I'm still using Windows 11), I'm not getting that error. Screenshot 2023-10-22 163930

jordimontana82 commented 11 months ago

@temmyraharjo based on your screenshot (which is really helpful!) it might be that there are still Debug configs floating around in .sln files, like:

https://github.com/DynamicsValue/fake-xrm-easy-messages/blob/2x-dev/FakeXrmEasy.Messages.sln#L21-L23

If you can try to remove those 3 lines from the .sln file to see if that fixes it for you? If so, I'll raise an issue to double check all repos.

temmyraharjo commented 11 months ago

Wow! Yes @jordimontana82, removing L21-L23 (Debug) and L42-L44 (Release) does fix the issue! Screenshot 2023-10-23 100153

bwmodular commented 11 months ago

Well that’s very exciting! I did try it again last week and did notice the problem was still there. Well done for finding the cause!

jordimontana82 commented 11 months ago

Yeah! The error was misleading in that it seemed it was an issue with the project file, but it was the solution instead.