dnu publish does not deploy all image and JavaScript files - asp.net

I use the following command to deploy an ASP.Net core 1.0 MVC application.
dnu publish --runtime active --no-source -o e:\website\zigs
Issue: Some image files and JavaScript files in the VS2015 project
wwwroot 'images' and 'js' folders are not deployed to the
'e:\website\zigs\wwwroot\' images and ..js sub-folders.
The missing files are present in the VS2015 project and all works correctly in the development environment.
I currently use dnvm version 1.0.0-rct1-15540 and dnx-clr-win-x86.1.0.0-rc1-update2
Is there something I need to do to flag the files to be included in the deployment?
(I can get around it by just manually deploying the missing files, but I would need to have the files deployed automatically by the build/deployment server in the future.)
Thank you.

Solved! Make sure the target root folder does not contain any folders/files to do with the deployment before running the dnu publish command!

Related

.NET Core: Separate .exe from other libraries when publishing self-contained apps

When you publish a .NET Core self-contained app right now, your exe is in the middle of a few dozen .NET Core runtime libraries, along with all the Nuget packages.
MyApp/
--ct/
--de/
--es/
...
--zh-Hant/
--Accessibility.dll
--api-ms-win-core-console.dll
... A dozen other .dlls
--MyApp.dll
--MyApp.exe
... Even more .dlls
I would like to set up publish so that these files are organized, like such
MyApp/
--netcoreapp3.0/
--nuget/
--MyApp.dll
--MyApp.exe
or even
MyApp.exe
MyApp/
--netcoreapp3.0/
--nuget/
--MyApp.dll
Alternatively, maybe there could be a way to change the directory of framework libraries in the .csproj <TargetFramework> tag? That way, I could use the framework-dependent publishing option and remove all the duplicate files.
If there is no constraint to use the framework-dependent publishing option you can publish with the PublishSingleFile option being true.
Your publish command would be
dotnet publish -c Release -r win-x64 /p:PublishSingleFile=true
Then in your publish folder you will find a "cleaner" result of an executable file, and some configuration files only (like appsettings.json or web.config). No nuget or runtime dlls.

What to copy for a .Net Core console application publish?

I have an incredibly simple .NET core console application that I'd like to publish into a self contained executable. My application uses an the Microsoft.Extensions.Configuration.Json package so I can use an appsettings.json file.
From the command line, in the .csproj folder, I run
dotnet publish --self-contained true -r win-x64
. Inside my Debug folder, I see a netcoreapp2.1 folder and then the win-x64 folder. Inside that folder, I see the following:
publish -> folder
myapp.deps.json
myapp.dll
myapp.exe
myapp.pdb
myapp.runtimeconfig.dev.json
myapp.runtimeconfig.json
appsettings.json
hostfxr.dll
hostpolicy.dll
Am I supposed to copy just the files from this directory or do i have to copy the entire publish folder along with the files to my destination on a Windows Server? Or did I miss a switch to condense these items down further so movement from server to server is even simpler?
Copying just the files from the win-x64 directory was not enough. I needed to copy up the entire publish folder and run the application from that directory, otherwise error messages such as not being able to find a dependency would occur.

Sharing .netcore project between windows and linux Keeps adding files

I am working on a group project and we have decided to use netcore for the project. The project was originally created using VS.
When I pull the project and run it using VSCode, I have noticed two things:
I have to navigate to the src folder and run it from there.
Before pushing new changes to the master branch, .netcore on linux has made changes to obj folder and added .vscode folder.
how can I stop this from happening so we don't step over each others toes, and why does this happen?
Thanks.
You should not add the files under obj to source control. It contains artifacts that are regenerated on every build.
If you use git, here's a suggested list of files and folders to ignore:
[Oo]bj/
[Bb]in/
.vs/
*.xap
*.user
/TestResults
*.vspscc
*.vssscc
*.suo
*.cache
*.docstates
_ReSharper.*
*.csproj.user
*[Rr]e[Ss]harper.user
_ReSharper.*/
packages/*
artifacts/*
msbuild.log
PublishProfiles/
*.psess
*.vsp
*.pidb
*.userprefs
*DS_Store
*.ncrunchsolution
*.log
*.vspx
/.symbols
nuget.exe
build/
*net45.csproj
*k10.csproj
App_Data/
bower_components
node_modules
*.sln.ide
*.ng.ts
*.sln.ide
project.lock.json
.build/
.testpublish/
launchSettings.json

What artifacts to ignore from version control in a .net core application

I am trying to learn to build a web application using .net core, mvc x and csharp. I am using visual studio code in OS X.
Here are the files and folders inside the freshly generated project directory:
Controllers
Dockerfile
Program.cs
Properties
README.md
Startup.cs
Views
appsettings.json
bower.json
bundleconfig.json
project.json
web.config
wwwroot
I think the following should be excluded and what else?
bin/
obj/
.vscode
wwwroot
I don't particularly exclude .vscode. It's convenient to share your tasks and debug profiles with others.
This is my .gitignore
node_modules/
**/bin/
**/obj/
**/*.VC.db* #vscode local database files
.vs/ #your friends who use visual studio
project.lock.json
TestResults/
.idea.* #ever heard of Jetbrains Rider?
**/appsettings.production.json
npm-debug.*

TeamCity MSbuild Deploy procedure

I'm using TeamCity for deployment process. For deploy i'm running MSbuild with this command line parameters:
/P:Configuration=Release
/P:DeployOnBuild=True
/P:DeployTarget=MSDeployPublish
/P:MsDeployServiceUrl=serviceUrl
/P:DeployIisAppPath=website
/P:AllowUntrustedCertificate=True
/P:MSDeployPublishMethod=WMSvc
/P:username=username
/P:Password=password
/P:SkipExtraFilesOnServer=True
/P:VisualStudioVersion=10.0
I have this parameter P:SkipExtraFilesOnServer set to true beacause i don't want MSbuild to delete some files which i have only on service enviroment, but don't have on my local project. But the problem is when i actually want to remove something from project (i have web application), i usually delete file from project, then i rebuild my app, and commit the changes in project file to source control, MSbuild leave this file on service because of this parameter.
MSbuild is using Release configuration, which i specified to use "all files in this project" to deploy. So the behaviour i want to implement:
TeamCity will leave all files which are not in my project reference list. (.csproj file).
TeamCity will delete files which were in .csproj but was deleted from it.
Please help me with that task.

Resources