Skip to content
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

Open-XML-SDK.sln fails to build with dotnet after adding .NET 3.5 support #205

Closed
MatthewMcD opened this issue May 8, 2017 · 12 comments
Closed
Assignees

Comments

@MatthewMcD
Copy link

Warning: Newbie Observation
I just want to use the PowerShell part of Open-XML-PowerTools. I am 5 hours into trying to get this code to build on a fresh install of VS Code and .Net Core. The brief build instructions are not enough to do the job. I'd be happy to write them up, but that would require success. If someone can assist me in getting the code to compile I'll repay the favor by writing it all into an updated "how to" for this project.

Right now I am stuck with:

dotnet restore .\Open-XML-SDK.sln
dotnet build .\Open-XML-SDK.sln /p:Configuration=Debug

I get the error: (I have tried to use TargetFramework=net46 but that fails with the same error.)

C:\Program Files\dotnet\sdk\1.0.3\Microsoft.Common.CurrentVersion.targets(1111,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v3.5" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [D:...\WindowsPowerShell\Modules\Open-XML-SDK\DocumentFormat.OpenXml\DocumentFormat.OpenXml.csproj]

@twsouthwick
Copy link
Member

Good catch! I had to switch it to use msbuild in order to get .NET 3.5 support (see PR #185). I would expect limiting the TargetFramework would work. Another option is we could change it so locally it continues to only build for .NET 4.5 and .NET Standard, but we build for the other targets on the build server. I'll investigate

@twsouthwick twsouthwick self-assigned this May 9, 2017
@twsouthwick twsouthwick changed the title Improve the "First Run" Documentation Open-XML-SDK.sln fails to build with dotnet after adding .NET 3.5 support May 9, 2017
@twsouthwick
Copy link
Member

I just tried with this command:

dotnet restore
dotnet build Open-XML-SDK.sln -f net46

and it builds fine.

Another option is to just build it with msbuild /t:restore;build which can build all the projects. dotnet doesn't know about the GAC so it can't get the .NET 3.5 references.

This probably isn't the best long term approach, so I'll keep the issue open until we close on what we should do so the widest developers can still build.

@twsouthwick
Copy link
Member

also, the OpenXML power tools can just reference the pre-built version of it from NuGet (pretty sure it has been updated to do that). Is there a need to build it yourself?

@MatthewMcD
Copy link
Author

MatthewMcD commented May 9, 2017

Nope, no need to build it, just no clear instruction (read: just want to use the darned thing) for me to follow to get the build to work. I tried running the PowerTools module and it crapped out with all sorts of failed dependencies on this project. So I am trying to get this project to build.

I know git and VS, but don't have VS2017 (or the desire to install it). Figured the lightweight approach was better, then ran into all these issues starting with the Power Tools and now the Open XML Libraries.

Within the VSCode/.NetCore toolchain, how does NuGet fit?

Tried

dotnet restore
dotnet build Open-XML-SDK.sln -f net46

Still fails as in my OP.

I am trying to build on Windows 10. (In case that matters.) but I have 4.6...I think:

PSChildName                      Version        Release Product
-----------                      -------        ------- -------
v2.0.50727                       2.0.50727.4927
v3.0                             3.0.30729.4926
Windows Communication Foundation 3.0.4506.4926
Windows Presentation Foundation  3.0.6920.4902
v3.5                             3.5.30729.4926
Client                           4.6.01586      394802  4.6.2
Full                             4.6.01586      394802  4.6.2
Client                           4.0.0.0

@twsouthwick
Copy link
Member

If all you need is to have a pre-built assembly, just grab it from NuGet: https://www.nuget.org/api/v2/package/DocumentFormat.OpenXml/2.7.1

Within the VSCode/.NetCore toolchain, how does NuGet fit?

NuGet is the package management solution the .NET ecosystem uses. As of VS2017 and the .NET CLI tooling, it is built into the tooling much more tightly. The dotnet restore is the same as nuget restore or msbuild /t:restore -- they're just different front ends to the same tools depending on where you are using it. NuGet is both the general technology as well as the distribution site https://www.nuget.org (but you can use private feeds to distribute as well). A package found on a NuGet feed will be in a zip with the extension .nupkg which can be extracted like any zip file and the net46 library, for instance, can be grabbed from there.

@MatthewMcD
Copy link
Author

MatthewMcD commented May 9, 2017

Taylor, I really appreciate the assistance. But still fail to see how to connect the dots. I just reviewed the video on Open XML Tools for "Gitting, Building, and Installing Open-Xml-PowerTools" and found my comment from 3 months ago asking why it does not build in VS2013+Update 4 as he said it would.

"If all you want to do is run in PowerShell you need to do the following." None of this is intuitive and assumes that Git, Slurp, Burp and dotnet, msbuild are all part of the readers every day life. So much of the "documentation" has comments like:

"The following instructions are somewhat outdated at this point."

followed by three paragraphs of installation instructions that do not work.

I am just offering to document it so it will actually build for a technical ITPro. After all, I use PowerShell and this is a PowerShell extension that appears to offer features to save me time...so far it is neither.

I don't meant to sound at all ungrateful! I really appreciate this type of community project. I'd just like to help the next person who stumbles in here with zero project history expecting to get the bits working.

@MatthewMcD
Copy link
Author

OK,
I just deleted everything. Then I ran:

git clone https://github.com/OfficeDev/Open-XML-SDK
git clone https://github.com/OfficeDev/Open-XML-PowerTools
cd .\Open-XML-SDK
dotnet restore 
Results for several restore completed without errors
dotnet build .\Open-XML-SDK.sln -f net46
 >Nothing but errors, mostly Reference Assemblies not found:
C:\Program Files\dotnet\sdk\1.0.3\Microsoft.Common.CurrentVersion.targets(1111,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.6" were not found. To resolve this, install the SDK or Targeting Pack ...
 >Do I need to reinstall .Net framework, Do I need to "target" a directory that .NetCore cannot find?

cd..
cd .\Open-Xml-PowerTools
dotnet restore .\OpenXmlPowerTools.sln
  Nothing to do. None of the projects specified contain packages to restore.
dotnet build .\Open-XML-PowerTools.sln -f net46
 >Nothing but errors, mostly Reference Assemblies not found. 

There is a .Net35.sln, but since I don't have 3.5 installed I am not trying that.

It seems that .Net Core has no idea how to find my .Net assemblies. Like there is a missing step in the "Getting Started with .Net Core".

@twsouthwick
Copy link
Member

I'm not that familiar with the Open XML Power Tools and sorry that they're out of date. We've finally got the Open-XML-SDK up and running and have plans to update the Power Tools, but no one is working on this full time.

I've updated things to work with the NuGet package better. Use this fork and branch of the power tools: https://github.com/twsouthwick/Open-Xml-PowerTools/tree/cleanup-sln

Notice that the build steps are greatly simplified.

I just deleted everything. Then I ran:

It looks like you don't have the targeting pack for .NET 4.6 installed. This will be required atm to build the power tools as well.

@MatthewMcD
Copy link
Author

Thanks again, I just installed the Developer Pack for 4.6.2 from here: https://www.microsoft.com/net/targeting. No Joy, screens full of read error messages telling me I am missing the real issue.

I appreciate your help, but for now I have COM code that works, even though I want to shower after I am done with it.

I'd be happy to be the guinea pig on any new steps to get a project up and running from bare metal.

@twsouthwick
Copy link
Member

hmmm... the developer pack for 4.6.2 won't contain the .NET 4.6 targeting pack. You can change the target framework of the library to 4.6.2 and compile with that or compile with .NET 4.6 after installing the targeting pack.

Can you share a screenshot of your errors?

@MatthewMcD
Copy link
Author

I will, but I am out of time for the next few days and have to find another solution. I'll get back on this thread when I am not under the gun. Thanks again for the help!

@MatthewMcD
Copy link
Author

Back at it...built a clean environment.
Installed VS2017 Community.
Cloned both projects into PowerShell\Modules.
Built the SDK without error.

Nothing is working, but it does build.
OfficeDev/Open-Xml-PowerTools#143

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

No branches or pull requests

2 participants