Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2017 RC How to specify Publishing Options in the csproj file

I have been working on VS2017 RC.

I ultimately want to run a react SPA project out of the ASPNETCORE project. To this end the template I was basing this on is a VS2015 one with a project.json file.

In the VS2015 project.json file I have two items that ordinarily do not appear in the standard ASPNETCORE template.

The two things I want to include are as follows:

 "publishOptions": {
"include": [
  "wwwroot",
  "web.config"
],
"exclude": [
  "node_modules",
  "**.xproj",
  "**.user",
  "**.vspscc"
  ]
},

  "scripts": {
    "prepublish": [
    "npm install",
    "node node_modules/webpack/bin/webpack.js --config    webpack.config.vendor.js",
    "node node_modules/webpack/bin/webpack.js"
],

I have looked high and low as to where you would add this to the csproj file. I have tried modifying the csproj file but after I do that the project crashes and ends up with various errors and warnings.

How do you add these into the project via VS2017?

How to you modify the csproj file outside the project without crashing your project.

like image 846
si2030 Avatar asked Feb 18 '17 07:02

si2030


1 Answers

You can refer to Project.json to MSBuild conversion guide

scripts:

{
  "scripts": {
    "precompile": "generateCode.cmd",
    "postpublish": [ "obfuscate.cmd", "removeTempFiles.cmd" ]
  }
}

<Target Name="MyPreCompileTarget" BeforeTargets="Build">
  <Exec Command="generateCode.cmd" />
</Target>

<Target Name="MyPostCompileTarget" AfterTargets="Publish">
  <Exec Command="obfuscate.cmd" />
  <Exec Command="removeTempFiles.cmd" />
</Target>

publishOptions:

  "publishOptions": {
    "include": [
      "files/",
      "publishnotes.txt"
    ]
  }

<ItemGroup> 
  <Content Include="files\**\*" CopyToPublishDirectory="PreserveNewest" />
  <None Include="publishnotes.txt" CopyToPublishDirectory="Always" />
  <!-- CopyToPublishDirectory = { Always, PreserveNewest, Never } -->
</ItemGroup>

I usually use notepad or notepad++ to edit .csporj then reopen visual studio 2017 :)

like image 153
Duran Hsieh Avatar answered Oct 19 '22 23:10

Duran Hsieh