PowerShell / Polaris

A cross-platform, minimalist web framework for PowerShell
https://powershell.github.io/Polaris/
MIT License
510 stars 113 forks source link

Build has one warning: MSB3277 #10

Closed TylerLeonhardt closed 6 years ago

TylerLeonhardt commented 7 years ago

The build currently has one warning:

/usr/local/share/dotnet/sdk/2.0.0/Microsoft.Common.CurrentVersion.targets(1987,5): warning MSB3277: Found conflicts between different versions of the same dependent assembly that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed. [/Users/tylerleonhardt/Desktop/CompSci/DotNET/Core/Polaris/PolarisCore/Polaris.csproj]
  Polaris -> /Users/tylerleonhardt/Desktop/CompSci/DotNET/Core/Polaris/PolarisCore/bin/Debug/netstandard2.0/Polaris.dll

Build succeeded.

Usually this is fixable by updating a dependency or adding a binding redirect. This is likely because we are using: <PackageReference Include="System.Management.Automation" Version="6.0.0-alpha17" /> from myget which supported .NET Standard 1.6.

BladeFireLight commented 6 years ago

I got an error. why is it wanting .net 4.5.1? I thought this was Core v2

C:\Program Files\dotnet\sdk\2.0.2\Microsoft.Common.CurrentVersion.targets(1122,5): error MSB3644: The reference assembli es for framework ".NETFramework,Version=v4.5.1" were not found. To resolve this, install the SDK or Targeting Pack for t his 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. [H:\Downloads \Polaris-master\PolarisCore\Polaris.csproj]

TylerLeonhardt commented 6 years ago

@BladeFireLight you're getting this because I'm in the process of making this backcompat with Windows PowerShell.

What OS are you on? Is this error happening when you build or when you import the module?

BladeFireLight commented 6 years ago

that error is at build. I have Win10 1709 and .Net 4.7.1

I changed the target to 4.7.1 and got it to build. and I also tried changing it to only target core. both of those got it to build.

but I cant get a single example to work. all of them just give 200 OK but no content.

TylerLeonhardt commented 6 years ago

So in response to the build error: you can safely ignore that error because the Core dll will still get generated. I'm still thinking about the right way to target these different frameworks. I'm surprised that you weren't able to target 451 even though you have 471.

You can also do: dotnet build -f netstandard2.0 to just build Core. For the future.

Now with respect to not getting a single example to work, what have you tried?

BladeFireLight commented 6 years ago

the hello world under win10 1709 and server 1709 under v6 beta 9 get the same blank content

PS C:\Users\Blade\Downloads\Polaris-master\Polaris-master> Import-Module ./Polaris.psm1
PS C:\Users\Blade\Downloads\Polaris-master\Polaris-master> get-command -Module Polaris

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        Get-RouteMiddleware                                0.0        Polaris
Function        Get-WebRoute                                       0.0        Polaris
Function        New-DeleteRoute                                    0.0        Polaris
Function        New-GetRoute                                       0.0        Polaris
Function        New-PostRoute                                      0.0        Polaris
Function        New-PutRoute                                       0.0        Polaris
Function        New-RouteMiddleware                                0.0        Polaris
Function        New-StaticRoute                                    0.0        Polaris
Function        New-WebRoute                                       0.0        Polaris
Function        Remove-RouteMiddleware                             0.0        Polaris
Function        Remove-WebRoute                                    0.0        Polaris
Function        Start-Polaris                                      0.0        Polaris
Function        Stop-Polaris                                       0.0        Polaris
Function        Use-JsonBodyParserMiddleware                       0.0        Polaris

PS C:\Users\Blade\Downloads\Polaris-master\Polaris-master> New-GetRoute -Path "/helloworld" -ScriptBlock {
>>     param($request,$response);
>>
>>     $response.Send('Hello World!');
>> }
PS C:\Users\Blade\Downloads\Polaris-master\Polaris-master> Start-Polaris

Port ScriptBlockRoutes                                                                    RouteMiddleware
---- -----------------                                                                    ---------------
8080 {[helloworld, System.Collections.Generic.Dictionary`2[System.String,System.String]]} {}

PS C:\Users\Blade\Downloads\Polaris-master\Polaris-master> Invoke-WebRequest -UseBasicParsing -Uri http://localhost:8080/helloworld

StatusCode        : 200
StatusDescription : OK
Content           :
RawContent        : HTTP/1.1 200 OK
                    Date: Sat, 11 Nov 2017 22:14:57 GMT
                    Server: Microsoft-HTTPAPI/2.0
                    Content-Length: 0
                    Content-Type: text/plain

Forms             :
Headers           : {[Date, System.String[]], [Server, System.String[]], [Content-Length, System.String[]], [Content-Type, System.String[]]}
Images            : {}
InputFields       : {}
Links             : {}
ParsedHtml        :
RawContentLength  : 0
RelationLink      : {}
TylerLeonhardt commented 6 years ago

@BladeFireLight :

where did you see to add:

param($request,$response); to your script blocks? You don't want to do that anymore as $request and $response are being pulled in from the global scope now.

By having that param statement, you're overwriting $request and $response with null.

If you found that in the docs, I need to fix that.

This breaking change happened in this PR: https://github.com/PowerShell/Polaris/pull/49

BladeFireLight commented 6 years ago

https://github.com/PowerShell/Polaris/wiki/$response.Send

https://github.com/PowerShell/Polaris/wiki/$response.SetContentType

https://github.com/PowerShell/Polaris/wiki/New-GetRoute

all over the wiki really.

are the docs some place else? all I see is the wiki.

TylerLeonhardt commented 6 years ago

@BladeFireLight no you're totally right for going there. I thought I updated it a while ago but I guess I didn't.

Thanks for that! I've updated all of the pages!

BladeFireLight commented 6 years ago

perfect. thanks

PS C:\Users\Blade\Downloads\Polaris-master\Polaris-master> Remove-WebRoute -Path helloworld -Method GET
PS C:\Users\Blade\Downloads\Polaris-master\Polaris-master> New-GetRoute -Path "/helloworld" -ScriptBlock {
>>     $response.Send('Hello World!');
>> }
PS C:\Users\Blade\Downloads\Polaris-master\Polaris-master> Invoke-WebRequest -UseBasicParsing -Uri http://localhost:8080/helloworld

StatusCode        : 200
StatusDescription : OK
Content           : Hello World!
RawContent        : HTTP/1.1 200 OK
                    Date: Sun, 12 Nov 2017 00:21:32 GMT
                    Server: Microsoft-HTTPAPI/2.0
                    Content-Length: 12
                    Content-Type: text/plain

                    Hello World!
Forms             :
Headers           : {[Date, System.String[]], [Server, System.String[]], [Content-Length, System.String[]], [Content-Type, System.String[]]}
Images            : {}
InputFields       : {}
Links             : {}
ParsedHtml        :
RawContentLength  : 12
RelationLink      : {}
TylerLeonhardt commented 6 years ago

Awesome! Let me know if you have any other issues!

copdips commented 6 years ago

@tylerl0706

Thx for the tips of dotnet build -f netstandard2.0, it works for me now.

FYI, I have a Windows 10.0.16299. I tested under Powershell v5.1 with dotnet v4.7.02556, and also tested under Powershell v6.0.2 with dotnet v2.1.101, both failed at Invoke-Build Build with following error :

C:\Program Files\dotnet\sdk\2.1.101\Microsoft.Common.CurrentVersion.targets(1126,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.5.1" were not found

Please kindly fix it.

TylerLeonhardt commented 6 years ago

@copdips You need the .NET Framework 4.5.1 Developer Pack in order to build against that framework: https://www.microsoft.com/en-us/download/details.aspx?id=40772

copdips commented 6 years ago

@tylerl0706

Thx, it works like a charm now, and thx for your flash commit on the README 👍

My 2 cents, installing .Net Dev Pack seems not sexy ... I remember that when I tested earlier versions of Polaris last year, Dev Pack was not necessary.

TylerLeonhardt commented 6 years ago

Great! Yeah I agree - 4.7.X seems to be the new standard for Windows 10. I'll probably end up switching to that. Doesn't require too big a change if you're interesting in contributing 😉

Development has slowed down a bit on this project because I switched teams but I expect it to pick up soonish once we open source some awesome PowerShell IoT stuff. PowerShell IoT + Polaris are a great combo.

TylerLeonhardt commented 6 years ago

No need to build anymore :)