I am using latest MacOS and latest version of Rider.
Seeking advise on how to set up build configuration for a hosted blazor wasm project. Created with this command:
dotnet new blazorwasm --hosted -o blazorhosted
I cd into blazorhosted/server and execute
dotnet run watch
and everything works as expected.
But I don't know how to run it in Rider. As a side not also works in VS Code with debugging on client and server.
This is the error I am getting when running the server configuration in Rider
Microsoft.NET.Sdk.Razor.StaticWebAssets.targets(184, 5): Duplicate base paths '/'
for content root paths '/Users/mha/projects/blazorhosted/Client/bin/Debug/netstandard2.1/wwwroot/'
and '/Users/mha/projects/blazorhosted/Client/wwwroot/'.
('/Users/mha/projects/blazorhosted/Client/obj/Debug/netstandard2.1/blazor/unlinked/blazorhosted.Client.dll',
'/Users/mha/projects/blazorhosted/Client/wwwroot/css/app.css')
Related
I have created a simple project by using the Service Stack Vue SPA template. I run the app by pressing F5, it works fine.
I am trying to find the way to make it working with app and web tools.
I tried this "app MyApp.dll" and it opens the app but blank and with "web MyApp.dll" it throws null reference exception.
Can you please help me get it working.
Regards,
Jamil
The web dotnet tool is only for .NET Core 2.1 Apps for .NET Core 3.1+ Apps you should use the new x dotnet tool:
$ dotnet tool install --global x
Please note only the app tool supports running in a .NET Core Windows Desktop App, for Console Apps just run the binary with the dotnet tool directly:
$ dotnet MyApp.dll
I followed your description and created a new vue-spa project:
$ x new vue-spa VueSpa
Then after publishing the App:
$ cd VueSpa\VueSpa
$ npm run publish
I can run the published binary with:
$ cd bin\Release\netcoreapp3.1\publish
$ app VueSpa.dll
Which runs it in a Windows Desktop App as expected:
On "Hosted VS2017" and self-hosted build agent (Windows Server 2012 R2), running dotnet publish with a publish profile specified fails with:
C:\Program
Files\dotnet\sdk\2.1.502\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(198,5):
error NETSDK1047: Assets file
'C:\agent_work\11\s\\obj\project.assets.json' doesn't have a
target for '.NETCoreApp,Version=v2.1/win-x64'. Ensure that restore has
run and that you have included 'netcoreapp2.1' in the TargetFrameworks
for your project. You may also need to include 'win-x64' in your
project's RuntimeIdentifiers.
On local dev server (Win10, VS2017, many different .net sdk versions) when I dotnet publish with the exact same command line, everything works great.
I have tried everything from updating VS2017, installing the exact version of .net core SDK and runtime that we're targeting, updating the build agent, windows updates... Nothing seems to help. I can't understand why it's having different behavior.
The publish profile is a FileSystem profile and has the following two elements specified:
<TargetFramework>netcoreapp2.1</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
The command line looks this: "C:\Program Files\dotnet\dotnet.exe" publish "C:\agent\_work\11\s\Source\TheProject.csproj" --no-build -c Release -f netcoreapp2.1 /p:PublishProfile="Publish Release To Filesystem.pubxml" -o C:\agent\_work\11\a\Website -v d
Does anyone have a clue what I can do to get this working?
This turns out to be all about the Runtime Identifier. The confusion arose because I assumed building and publishing from dotnet-cli was as simple as building and publishing from Visual Studio. Visual Studio's publish was doing a full restore/build with its publish, and the publish profile had the <RuntimeIdentifier> set.
I was doing several things wrong. I wasn't including -r win-x64 to the restore and build tasks, and I was using dotnet publish --no-build. So that's where one mismatch came from. The next was that I was running dotnet test after build and before publish. That was wiping out some things that publish needed, not sure what though.
I changed dotnet test to include -p:RuntimeIdentifier=winx64 since apparently it uses -r for reporting output (apparently they're adding -runtime in 2.2).
Some things I learned in the process, dotnet-cli does NOT work well with .sln files, at least in build agent's. It seems to have a big problem with file locks and shared processes. Trying to optimize build tasks to minimize work with the dotnet-cli is a major pain in the ass.
I think Jay covered this in the other answer, but to clarify what worked for me was running:-
dotnet restore <path/to/.sln> -r linux-x64
just before running the dotnet msbuild command. (Obviously replace linux-x64 with your target).
I have a problem with a dotnet core project of mine. I have a TFS build that does a "dotnet publish" and deploys the application to IIS.
The publish command looks like this:
dotnet publish -o $(build.stagingDirectory) -c Release --self-contained --runtime win81-x64
My code hasn't changed but now I get the following error when I run the build on the TFS:
NETSDK1067: Self-contained applications are required to use the application host. Either set SelfContained to false or set UseAppHost to true.
We updated the build server to the newest .NET Core SDK last week so I guess it probably has something to do with that.
What changed and what can I do to make the build work again?
I have tried to run the out of the box Blazor application to try out C# WebAssembly. I am running into issues when trying to run it different ways. I have also tried to hack the runtimeconfig.json according to this https://github.com/dotnet/cli/issues/7543
Running IIS Express
Running BlazorApplication1
The program '[42032] dotnet.exe' has exited with code -2147450749 (0x80008083).
Running in command line
It was not possible to find any compatible framework version
The specified framework 'Microsoft.NETCore.App', version '2.0.0-preview3-25512-01' was not found.
- Check application dependencies and target a framework version installed at:
\
- Alternatively, install the framework version '2.0.0-preview3-25512-01'.
You need to have the 2.1 preview of the .net core framework installed for Blazor to work: download here
We have a VS 2017 solution with one WCF-service project and one .net-core web-application targeting .net framework 4.5.2 and .net core 1.0 (1.0.0-preview2-003131).
By some reason I cannot get the website published through "dotnet publish"-command in visual studio team services.
The problem shows up in build step "dotnet publish", project is specified to match only the web-projects solution-file (**/InventoryIndexWeb.csproj) since I only want the web to be published in this build.
Gives the following errors:
MSBUILD : error MSB1008: Only one project can be specified.
Dotnet command failed with non-zero exit code on the following projects : d:\a\3\s\WebSites\InventoryIndex\Staging\InventoryIndexWeb\InventoryIndexWeb.csproj
See screenshot for details:
Any suggestions how to solve this or workarounds? The plan is to push this to Octopus deploy as well when we get the publish step working.
You cannot pass multiple projects / arguments to dotnet publish.
In your case you seem to have passed the artifacts folder as second argument. To do this, add -o before that directory:
dotnet publish your.csproj -o $(Build.ArtifactStagingDirectory)
Changing to pass -o as parameter instead of only $(Build.ArtifactStagingDirectory) did the trick as Martin stated above, and final configuration as below.