Skip to content

Predefined Type '' is not defined or imported #226

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

Closed
interfacemirror opened this issue Apr 23, 2018 · 5 comments · Fixed by #236
Closed

Predefined Type '' is not defined or imported #226

interfacemirror opened this issue Apr 23, 2018 · 5 comments · Fixed by #236

Comments

@interfacemirror
Copy link

Hello Scott,

After including Sparkle package in my solution from Nuget, I get so many errors saying "Predefined Type '' is not defined or imported". It seems that after the import it does something with the solution and package and causing the error.

I am using Dynamics 365 SDK version 9.0.0.7 and VS 2017.

@janis-veinbergs
Copy link
Contributor

Hello @scottdurow. Same with me. I see you have committed vsix for Script# for VS2017 which I have installed. However build fails because of these errors.

Looking at references I see that mscorlib has yellow exclamation mark there and it says Version 0.0.0.0 within properties. I suspect it cannot find Script# DLL. However it IS located here: SparkleXrmTemplateVS2016DeveloperToolkit365\packages\ScriptSharp.0.7.5.1\tools\mscorlib.dll

I'v verified that ClientUI.csproj has this line: <Import Project="..\packages\ScriptSharp.0.7.5.1\tools\ScriptSharp.targets" Condition="Exists('..\packages\ScriptSharp.0.7.5.1\tools\ScriptSharp.targets')" /> and that .targets file is identical to some old VS2012 project which works.

I have this in msbuild log:

1>  Dependency "mscorlib, Version=0.7.0.0, Culture=neutral, PublicKeyToken=8fc0e3af5abcb6c4".
1>      Could not resolve this reference. Could not locate the assembly "mscorlib, Version=0.7.0.0, Culture=neutral, PublicKeyToken=8fc0e3af5abcb6c4". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

And i DO NOT have this in log file (compared to sucessfull build on other project in VS2012):

1>Target "BuildScript" in file "C:\Users\JanisV\Development\Source\CRM\DEAC.CRM.CRM\DEAC.CRM.ConnectionsUI\packages\ScriptSharp.0.7.5.1\tools\ScriptSharp.targets" from project "C:\Users\JanisV\Development\Source\CRM\DEAC.CRM.CRM\DEAC.CRM.ConnectionsUI\ClientUI\DEAC.CRM.ConnectionsUI.ClientUI.csproj" (target "Build" depends on it):
1>Using "ScriptCompilerTask" task from assembly "C:\Users\JanisV\Development\Source\CRM\DEAC.CRM.CRM\DEAC.CRM.ConnectionsUI\packages\ScriptSharp.0.7.5.1\tools\ScriptSharp.Build.dll".

The ScriptSharp.targets probably get parsed, because I see:

1>BuildDependsOn = 
1>            RestorePackages;
1>            
1>      EntityDeploy;
1>      
1>      BeforeBuild;
1>      CoreBuild;
1>      AfterBuild
1>    
1>    ;
1>        ;BuildScript

Regarding SparkleXrm\NuGet\ScriptSharp.vsix - what should it do when I install it?I see v7.6.0 under %localappdata%\Microsoft\VisualStudio\15.0_9d3398e1\Extensions\bpy2lfef.tnj\Packages\ScriptSharp.0.7.6.0.nupkg but this package doesn't appear. Added this path manually to NuGet packages, updated ScriptSharp to 0.7.6.0 - still same issue.

Tried removing/adding mscorlib manually to references and it says: A reference to ...\mscorlib.dll could not be added. This component is already automatically referenced by the build system.. Except it cannot find mscorlib.dll during the build :(

@scottdurow
Copy link
Owner

There was a recent change to VS2017 that means that you need to update the project to work with Script# - there isn't any need to update the Script# visx as per the one I put in the gallery https://marketplace.visualstudio.com/items?itemName=ScottDurowMVP.ScriptSharp

Open the project csprj and add the DisableHandlePackageFileConflicts property as you can see here -

<DisableHandlePackageFileConflicts>true</DisableHandlePackageFileConflicts>

@janis-veinbergs
Copy link
Contributor

janis-veinbergs commented May 9, 2018

Found another piece of info:

1>          mscorlib, Version=0.7.0.0, Culture=neutral, PublicKeyToken=8fc0e3af5abcb6c4, processorArchitecture=MSIL
1>                  HintPath=C:\Users\JanisV\Development\Source\SparkleXrmTemplateVS2016DeveloperToolkit365\packages\ScriptSharp.0.7.6.0\tools\mscorlib.dll (TaskId:10)
1>  Task Parameter:TargetFrameworkDirectories=C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0 (TaskId:10)
1>  Encountered conflict between 'Reference:mscorlib, Version=0.7.0.0, Culture=neutral, PublicKeyToken=8fc0e3af5abcb6c4, processorArchitecture=MSIL' and 'Platform:mscorlib.dll'.  Choosing 'Platform:mscorlib.dll' because AssemblyVersion '4.0.0.0' is greater than '0.7.0.0'. (TaskId:10)

This looks very relevant: fsprojects/Paket#2740
Yeah, adding <DisableHandlePackageFileConflicts>true</DisableHandlePackageFileConflicts> solves the issue and build succeeds!. Looks like some breaking change in Visual Studio 2017.3

Probably a new VS2017 template should be created or SparkleXrmTemplateVS2016DeveloperToolkit365 updated?

@scottdurow
Copy link
Owner

Yeah - you're right - we need to update the template for this. Any takers?

janis-veinbergs added a commit to janis-veinbergs/SparkleXrm that referenced this issue May 9, 2018
Due to Visual Studio 2017 changes in how assemblies are resolved. Now project can be built using Visual Studio 2017
@janis-veinbergs
Copy link
Contributor

Thanks for quick responses. Looks like you had sorted that out.
Would you explain please what is the correct way to kickstart project using VS2017? Because tutorials seems outdated and looks like you actually had this fix, but within different project. Was it just to build SparkleXRM but not SparkleXRM solutions?

Maybe other templates also need including these directives?

scottdurow pushed a commit that referenced this issue May 21, 2018
Due to Visual Studio 2017 changes in how assemblies are resolved. Now project can be built using Visual Studio 2017
scottdurow added a commit that referenced this issue Dec 12, 2019
* Resolves #176

* Updated dependancies to v9

* 1.0.4 Updated assembly name and added dependnacy on fakeiteasy

* Added support for setting all ExecutionContext properties

* Fixes #218 & SetState & SetStateDynamicEntity message property of EntityMoniker (#220)

* Fixes #218

* SetState & SetStateDynamicEntity use message property of EntityMoniker

* Fixes #232

* Version 1.0.6

* ix dependency load error - Cannot resolve dependency to assembly 'Sy…
…stem, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event. site:stackoverflow.com

* Fix #226: Predefined Type '' is not defined or imported (#236)

Due to Visual Studio 2017 changes in how assemblies are resolved. Now project can be built using Visual Studio 2017

* Fixed typo (#280)

* Fix some typos (#311)

* Let OOB batch files to pass parameters like "/p" to spkl.exe

* Add support for workflow base class
Fix dependency load error
scottdurow added a commit that referenced this issue Jun 30, 2020
* Spkl dev 191212 (#347)

* Resolves #176

* Updated dependancies to v9

* 1.0.4 Updated assembly name and added dependnacy on fakeiteasy

* Added support for setting all ExecutionContext properties

* Fixes #218 & SetState & SetStateDynamicEntity message property of EntityMoniker (#220)

* Fixes #218

* SetState & SetStateDynamicEntity use message property of EntityMoniker

* Fixes #232

* Version 1.0.6

* ix dependency load error - Cannot resolve dependency to assembly 'Sy…
…stem, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event. site:stackoverflow.com

* Fix #226: Predefined Type '' is not defined or imported (#236)

Due to Visual Studio 2017 changes in how assemblies are resolved. Now project can be built using Visual Studio 2017

* Fixed typo (#280)

* Fix some typos (#311)

* Let OOB batch files to pass parameters like "/p" to spkl.exe

* Add support for workflow base class
Fix dependency load error

* Fix dependency load error (#346)

* ix dependency load error - Cannot resolve dependency to assembly 'Sy…
…stem, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event. site:stackoverflow.com

* Add support for workflow base class
Fix dependency load error

* #308 Removed dependency on OrganizationServiceProxy that does not support OAuth

* 🧹 Fixed typo and formatting

* 🧹 Code formatting clean up

* 🧪 Unit/Integration Test Playlists

* 📦 Updated to latest nuget packages

* Added FilteringService dependencies

* Removed WindowsForms reference from nuget package as it's no longer included in the SDK

* Updated nuget spec to depend on CoreTools 9.1.0.25

* Compare web resources content before update (#352)

* Comparing WebResource content, to skip unnecessary update

* Comparing WebResource content, to skip unnecessary update

* Ability to specify earlybound types as array, not single string with comma separator

* #354 Export command
🧹 Code formatting tidy up

* Use xrm tooling for command line login prompt (#373)

* #369 New Command Line Login using Xrm.Tooling

* Added message about /l legacy login switch

* #366 - Allow registering of combined plugin/wf activity libraries (#374)

* 🐛 Pick up Release assembly when in Release mode

Co-authored-by: Andy Elsmore <[email protected]>
Co-authored-by: pawelgradecki <[email protected]>
janis-veinbergs added a commit to janis-veinbergs/SparkleXrm that referenced this issue Feb 18, 2022
…ottdurow#236)

Due to Visual Studio 2017 changes in how assemblies are resolved. Now project can be built using Visual Studio 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants