A web project that includes typescript and makes use of the "Redirect Javascript output to folder" option can currently not be published (local file system) because Microsoft.TypeScript.targets does not honor TypeScriptOutDir when populating FilesForPackagingFromProject and/or other MSBuild variables.
This is a small snippet extracted from my .csproj file:
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<TypeScriptSourceMap>True</TypeScriptSourceMap>
<TypeScriptModuleKind>amd</TypeScriptModuleKind>
<TypeScriptOutDir>$(ProjectDir)Scripts\ts</TypeScriptOutDir>
</PropertyGroup>
The offending option is TypeScriptOutDir. If I remove it, publishing works as expected.
Did anyone else experience the same problem and has comeup with a work-around? I don't care if a fix would involve editing Microsoft.TypeScript.targets.
Related
I am using Visual Studio 2019 and trying to exclude wwwroot\js\src files from getting copied to IIS when publishing. Similar questions have been asked but those what I have referred to don't work because some of the project file syntax shown in those examples are not valid. Even the Microsoft documented method is not working.
MS Official documentation - wpp.target files has no effect on publish. It still copies the wwwroot\js\src files.
This - In vs 2019; CopyToPublishDirectory is not a valid attribute to Content tag. However the valid syntax below:
<ItemGroup>
<Content Update="wwwroot\js\src\**">
<CopyToPublishDirectory>false</CopyToPublishDirectory>
</Content>
</ItemGroup>
still publishes the js\src folder to IIS.
This - doesn't help either.
This must be quite a simple task and yet not straight forward way to get it done. Any help is appreciated.
Well,
This syntax worked after I add it to the csproj file. However the according to intellisense says it's invalid, but it works. Seems to be an issue on Microsoft side
<ItemGroup>
<Content Update="wwwroot\js\src\**\*">
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</Content>
</ItemGroup>
The tooltip says CopyToPublishDirectory can only have a boolean value of true/false
and If I do that this doesn't work!
I'm not used with "publishing" a project via visual studio. I'm trying to do so since yesterday and I've found out these things:
All the images contained in my application in a specific folder (example: MyProject/Images/Image1.jpeg) are only copied the same way they are in my project;
None of my controllers/utility class appears in the published project;
However the views are presents and the javascript files as well, but as they are, so a MyApp.js will be copied as a MyApp.js.
So my question is: is it supposed to be that way? What about my logic, ain't it not supposed to be copied as well? And shouldn't it be compressed, compiled, or protected in a dll, else everyone will be able to see my code in public, which I do not want?
Feel free to teach me what's a publish is supposed to do and what went wrong. thanks!
Publish is supposed to do almost what you mentioned only..
Images in content folder
any stylesheets in the content folder
Scripts in script folder
All View files Anything with Build Action = Content
The compiled files form the dll of your binary & dependencies
Infact all the images, css, javascripts will also have buildaction set to content only.
If you have a file selected in the project and it is not found in the folder, if its build action is "content", the build will succeed but the publish may fail. So in this case you may have to exclude the file if it is not necessary or add the file in the folder
Most of the automatic build systems like cruise control also do the same though with quite an advanced interface.
Your logic in c# or vb.net is already compiled into the binaries. But any script or styles or scripts inside html won't be protected. But bundling the scripts and styles using the BundleConfig may protect it to some extent.
All Your logic is converted into dll's so just create an instance on IIS and host your application there. You can follow the steps shown here.
I just upgraded to the latest version of WebEssentials v3 and the TS files in my ASP MVC 4 project aren't compiling to JS anymore. I verified that the Options --> Text Editor --> TypeScript --> Project --> Automatically compile TypeScript files which are part of a project option is checked, but nothing happens when I save or compile my project. I've tried deleting the existing .js and .min.js files that WE2 created, but that didn't help. I tried adding a new TS file to my project that and didn't generate a JS file. I reinstalled TS 0.9.1.1 and that didn't help.
Sooooo what to do? Am I missing something obvious? Is something not working or do I just have the wrong expectations?
Do I need to go back to WE2?
Update: I even created a brand new ASP MVC 4 C# project to verify it wasn't just my original project, but I got the same results.
Interestingly enough, I just created a new TypeScript project and my TS files compiled properly on save... So that's interesting..
There are some links in the change log of WE3, here is the one describes how to enable the compile-on-save feature, see http://typescript.codeplex.com/wikipage?title=Compile-on-Save for details.
I've created a nuget package called Ltc.MSBuild.TS0911WE3.targets which will do the trick for you, just open Package Manager Console, type in Install-Package Ltc.MSBuild.TS0911WE3.targets!
Go to Ltc.MSBuild.TS0911WE3.targets on nuget.org.
I'm not sure if this is the correct method of dealing with the problem, but here's what I did to get "compile on save" working on my project...
After noticing that Compile On Save worked when starting from a new HTML Application with TypeScript project, I did a comparison between that and my non-working ASP MVC project. Turns out, my ASP MVC project was missing this bit of code..
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<TypeScriptTarget>ES3</TypeScriptTarget>
<TypeScriptRemoveComments>false</TypeScriptRemoveComments>
<TypeScriptSourceMap>true</TypeScriptSourceMap>
<TypeScriptModuleKind>AMD</TypeScriptModuleKind>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<TypeScriptTarget>ES3</TypeScriptTarget>
<TypeScriptRemoveComments>true</TypeScriptRemoveComments>
<TypeScriptSourceMap>false</TypeScriptSourceMap>
<TypeScriptModuleKind>AMD</TypeScriptModuleKind>
</PropertyGroup>
<Import Project="$(VSToolsPath)\TypeScript\Microsoft.TypeScript.targets" />
Copy/pasting that into my ASP MVC project gave me Compile On Save support again. Of course, it's still not exactly what I expected. The resultant JS files are not added to the project automatically, so that's something I had to do manually. I also had to manually group the JS file with the TS file to mimic the same experience I was getting with WE2.
Hope that helps someone. Would love to hear some feedback on the solution.
Make sure your .proj file has a TypeScriptCompile XML section. You can copy from the typescript project if its not present.
Here is the specification : https://msbuildtypescript.codeplex.com/
using the "web essentials" tool (free, recomended) enable the preview pane in the web essentials options
Tools --> Options --> Web essentials --> Typescript: Show Preview Pane[X]
Now every time you save an open TS file, web essentials makes sure the file compiles (so it can display it) and you can update your javascript code while the project is running.
Starting to make a lot of use out of the build events system in XE, but one thing I noticed is that I'm unable to set up default build events in the default project settings. Is there any sort of workaround/hack/whatever that would make this possible? I'm looking at CodeGear.Group.Targets and CodeGear.Delphi.Targets in the bin directory, if this is even doable, would that be where I should be looking?
Thanks
Ah ha. Answered my own question. (Is there a delete button somewhere? Lol)
I did some experimenting, added some easy to find pre and post build events (namely launching the registry editor and notepad..)
In Delphi's bin directory there's a file called CodeGear.Delphi.Targets. Inside that, after the import sections, I added:
<PropertyGroup>
<PreBuildEvent><![CDATA[regedit.exe]]></PreBuildEvent>
<PostBuildEvent><![CDATA[notepad.exe $(MSBuildProjectFile)]]></PostBuildEvent>
</PropertyGroup>
Restarted the IDE, and a new empty project executed those programs on pre and post build. Note that they don't show up on the project configuration screen though, but you can override them, negating whatever was put in the CodeGear.Delphi.Targets file. Cheap, but it seems to do the trick, and you can still override it if needed on a specific project. (Just make sure to back the original file up of course.)
#Jen Smith: Very clever. And in case someone is interested I've now used your idea to get madExcept to patch the binary exe as part of a command line build without having to customise a specific project..:
Put this after the 'Import' section of CodeGear.Delphi.Targets..
<PropertyGroup>
<PostBuildEvent><![CDATA["$(programFilesx86)\madCollection\madExcept\Tools\madExceptPatch.exe" "$(DCC_ExeOutput)$(MSBuildProjectName).exe" "$(MSBuildProjectDirectory)\$(MSBuildProjectName).mes"]]></PostBuildEvent>
</PropertyGroup>
My view has errors. I see these errors only if I open the view in Visual Studio.
I would like to see the errors on compile time rather than on execute time.
Does exist a way to obtain this behavior?
You can update by hand the .csproj file and add a <MvcBuildViews>true</MvcBuildViews> that will compile the views as you go.
Here's a link I googled, you'll find others as well.
EDIT: If it's too slow try setting the build only for Release, edit the csproj file doing something like this; see the docs for AspNetCompiler for more details.
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
-->
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
<AspNetCompiler VirtualPath="Temp" PhysicalPath="$(ProjectDir)\..\$(ProjectName)" />
</Target>
I assume you are talking about C# compile errors and not things like CSS validation errors.
One thing you can do is add a Web Deployment Project to your solution. When it builds, it will run aspnet_compiler.exe on your project which will expose any of these C# compile errors in .aspx files that otherwise wouldn't be indicated until the .aspx file was compiled on the fly at runtime.